4

We are using Behat with Mink. So far we used to just set the DesiredCapabilities in the code, but now we want to change that to get them from the behat.yml and use different profiles, so we have one profile for firefox, one for chrome... and so on.

Now this is my behat.yml at the moment:

chrome:
 extensions:
  Behat\MinkExtension:
   sessions:
    default:
      selenium2:
        wd_host: "http://localhost:4444/wd/hub"
        capabilities:{"browserName":"chrome","version":"51","platform":"ANY","browserVersion":"51","browser":"chrome","name":"Behat Test","deviceOrientation":"portrait","deviceType":"tablet", "selenium-version":"2.31.0"}

When I try to start a test with profile chrome I get this error:

 [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]Unrecognized option "selenium-version" under testwork.mink.sessions.default.selenium2.capabilities"                                                      

If I remove the 'selenium-version' part it just jumps into using the default capabilities defined in Selenium2Driver.php

Any idea why this happens? After all, the default Capabilities of Selenium2 use selenium-version too...

yeaitsme
  • 91
  • 1
  • 9
  • Check [this blog](http://www.inanzzz.com/index.php/posts/behat) to see if it helps. There are many behat.yml and actual test examples. Example: http://www.inanzzz.com/index.php/post/6djs/running-behat2-tests-with-different-browsers – BentCoder May 09 '17 at 12:48

1 Answers1

3

Yes, you have the option to set custom capabilities in behat.yml . There is a key in capabilities array so called extra_capabilities. All the capabilites which were set there going to be merged with the known one. Its done inside MinkExtension/ServiceContainer/Driver/Selenium2Factory.php in the getCapabilitiesNode method. You also can find there all the capabilities supported by Behat/Mink

So try to use it in the next way:

capabilities:{"browserName":"chrome","version":"51","platform":"ANY","browserVersion":"51","browser":"chrome","name":"Behat Test","deviceOrientation":"portrait","deviceType":"tablet", "extra_capabilities": {"selenium-version":"2.31.0"}}

That extra parameters also will be passed to the selenium server

Igor Lantushenko
  • 1,771
  • 10
  • 19