I want run behat tests in certain browsers so when I type something like this bin/behat firefox
or bin/behat chrome
or bin/behat opera
tests should be run under respective browsers. Is it possible? If so, how should I modify my yml below or anything else? The reason I need such thing is that the selenium sometimes doesn't like some browsers based on its version.
I read thru this post but I didn't quiet get it to apply to my behat.yml
behat.yml:
default:
context:
class: Football\LeagueBundle\Features\Context\FeatureContext
parameters:
output_path: %behat.paths.base%/test/report/behat/output/
screen_shot_path: %behat.paths.base%/test/report/behat/screenshot/
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Behat\MinkExtension\Extension:
base_url: 'http://symfony.local/app_test.php/'
files_path: %behat.paths.base%/test/dummy/
browser_name: firefox
goutte: ~
selenium2: ~
paths:
features: %behat.paths.base%/src
bootstrap: %behat.paths.features%/Context
example feature
Feature: Visit Home Page
In order to see hello message
As a user
I should be able to visit home page
#SUCCESS
@javascript
Scenario: I visit home page
When I go to "/"
Then I should see "Hello Symfony!"
#FAIL
@javascript
Scenario: I visit home page
When I go to "/"
Then I should not see "Hello Behat!"
The documentation sucks again and again, so you'll need to play around with the config. I'm sure there are a few ways you can achieve this, but the proposed way with profiles should be the simplest. If I get everything correctly it can be done like this.
default:
context:
class: Football\LeagueBundle\Features\Context\FeatureContext
parameters:
output_path: %behat.paths.base%/test/report/behat/output/
screen_shot_path: %behat.paths.base%/test/report/behat/screenshot/
extensions:
Behat\Symfony2Extension\Extension:
mink_driver: true
kernel:
env: test
debug: true
Behat\MinkExtension\Extension:
base_url: 'http://symfony.local/app_test.php/'
files_path: %behat.paths.base%/test/dummy/
browser_name: firefox
goutte: ~
selenium2: ~
paths:
features: %behat.paths.base%/src
bootstrap: %behat.paths.features%/Context
chrome:
extensions:
Behat\MinkExtension\Extension:
browser_name: chrome
firefox:
extensions:
Behat\MinkExtension\Extension:
browser_name: firefox
I'm not 100% certain, but I remember that Behat merges default profile with the other ones, so hopefully you don't have to copy everything, if that doesn't work, then try defining the complete profile.
Also, have a look at this comment, you can define what tags to include with each profile, which might be quite useful if you want only certain tests running in certain browsers.
To run it you specify the profile:
$ behat -p firefox
$ behat -p chrome