问题
This is my behat.yml file :
firefox:
suites:
firefox:
contexts:
-FeatureContext
extensions:
Behat\MinkExtension:
javascript_session: selenium2
base_url: https://example.com
selenium2:
wd_host: username:pwd@ondemand.saucelabs.com/wd/hub
browser: firefox
capabilities: {'platform':'OS X 10.10', 'browser':'firefox', 'version':'42.0', "screen-resolution":"1280x1024"}
Which is giving error "
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized option "screen-resolution" under "testwork.mink.sessions.selenium2.selenium2.capabilities"
I have tried this https://groups.google.com/forum/#!topic/behat/kApbLIiAkOg, but I am also getting exactly same error.
If I configure SauceLabsDriver then only I will get all (https://github.com/Behat/MinkExtension/blob/master/doc/index.rst#sessions) - special flavor of the Selenium2Driver
The above document is suggesting modify your behat.yml profile:
default:
extensions:
Behat\MinkExtension:
sessions:
my_session:
sauce_labs: ~
But no idea how to implementing this. Any idea? How to change behat.yml file with saucelabs to use all those customization parameters.
回答1:
Although this is for behat 2, could you please try Resizing browser window size with behat2.
class FeatureContext extends MinkContext
{
/**
* @BeforeScenario
*/
public function resizeWindow()
{
$this->getSession()->resizeWindow(1440, 900, 'current');
}
}
回答2:
Using resize with @BeforeScenario
hook can be not optimal.
Another way is to use a scenario step
/**
* @Given /^I set browser window size to "([^"]*)" x "([^"]*)"$/
*/
public function iSetBrowserWindowSizeToX($width, $height) {
$this->getSession()->resizeWindow((int)$width, (int)$height, 'current');
}
And if needed to maximize it back
/**
* @Given /^I maximize browser window size$/
*/
public function iSetBrowserWindowSizeToX($width, $height) {
$this->getSession()->resizeWindow((int)$width, (int)$height, 'current');
}
来源:https://stackoverflow.com/questions/34425759/how-to-customize-screen-resolution-with-saucelabs-selenium-behat3-0-mink-capa