php - Behat3 MinkExtension could not be enabled -
i want achieve take screenshot using behat, mink , seleniumgrid
but errors:
given go "mysite.org/private" # featurecontext::visit() mink instance has not been set on mink context class. have enabled mink extension? (runtimeexception) │ ╳ mink instance has not been set on mink context class. have enabled mink extension? (runtimeexception) │ └─ @afterstep # feat
my 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
my featurecontext.php
class featurecontext extends minkcontext { private $screenshotpath; public function __construct() { $this->screenshotpath = "/app/screenshot"; } /** * take screen-shot when step fails. works 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 css selector "([^"]*)"$/ * @then /^i should see 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' not contain css selector '%s'", $this->getsession()->getcurrenturl(), $css_selector)); } } /** * @then /^i should not see css selector "([^"]*)"$/ * @then /^i should not see 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 css selector '%s'", $this->getsession()->getcurrenturl(), $css_selector)); } } }
has ideas? thx
probably looking examples problem in behat.yml
configuration file. default
name of profile , extensions
key child of profile. each line below default
profile should has addition 4 spaces.
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
Comments
Post a Comment