Behat、Mink、SeleniumGridを使ってスクリーンショットを撮りたい
しかし、私はこのエラーが発生します:
"mySite.org/private" # FeatureContext::visit() にアクセスすると、Mink インスタンスが Mink コンテキスト クラスに設定されていません。Mink 拡張機能を有効にしましたか? (RuntimeException) │ ╳ Mink インスタンスが Mink コンテキスト クラスに設定されていません。Mink 拡張機能を有効にしましたか? (RuntimeException) │ └─ @AfterStep # Feat
私のbehat.yml:
default:
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://integration.fvs.dev.intern.etecture.de/private-clients
browser_name: 'firefox'
selenium2:
wd_host: http://hub.selenium.intern.etecture.de:4444/wd/hub
capabilities: { "browser": "firefox", "version": "14"}
goutte: ~
sessions:
goutte:
goutte: ~
selenium2:
selenium2: ~
symfony2:
symfony2: ~
suites:
backend:
type: symfony_bundle
mink_session: selenium2
contexts:
- app\features\bootstrap\FeatureContext:
screen_shot_path: app/screenshot
私のFeatureContext.php
class FeatureContext extends MinkContext
{
private $screenShotPath;
public function __construct()
{
$this->screenShotPath = "/app/screenshot";
}
/**
* Take screen-shot when step fails. Works only with Selenium2Driver.
*
* @AfterStep
* @param AfterStepScope $scope
*/
public function takeScreenshotAfterFailedStep(AfterStepScope $scope)
{
if (99 === $scope->getTestResult()->getResultCode()) {
$driver = $this->getSession()->getDriver();
if (! $driver instanceof Selenium2Driver) {
return;
}
if (! is_dir($this->screenShotPath)) {
mkdir($this->screenShotPath, 0777, true);
}
$filename = sprintf(
'%s_%s_%s.%s',
$this->getMinkParameter('browser_name'),
date('Ymd') . '-' . date('His'),
uniqid('', true),
'png'
);
$this->saveScreenshot($filename, $this->screenShotPath);
}
}
/**
* @Then /^I should see the css selector "([^"]*)"$/
* @Then /^I should see the CSS selector "([^"]*)"$/
*/
public function iShouldSeeTheCssSelector($css_selector) {
$element = $this->getSession()->getPage()->find("css", $css_selector);
if (empty($element)) {
throw new \Exception(sprintf("The page '%s' does not contain the css selector '%s'", $this->getSession()->getCurrentUrl(), $css_selector));
}
}
/**
* @Then /^I should not see the css selector "([^"]*)"$/
* @Then /^I should not see the CSS selector "([^"]*)"$/
*/
public function iShouldNotSeeAElementWithCssSelector($css_selector) {
$element = $this->getSession()->getPage()->find("css", $css_selector);
if (empty($element)) {
throw new \Exception(sprintf("The page '%s' contains the css selector '%s'", $this->getSession()->getCurrentUrl(), $css_selector));
}
}
}
誰かアイデアはありますか?どうも