Checking test execution in different browsers
I want to run tests of behavior on specific browsers, so when I type something like this, the tests bin/behat firefox
or bin/behat chrome
or bin/behat opera
should run on the respective browsers. Is it possible? If so, how do I change my yml below or something else? The reason I need such a thing is because selenium sometimes doesn't like some browsers based on its version.
I read through this post but I didn't shut up to apply it 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: 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!"
source to share
The documentation sucks over and over again, so you'll need to play around with the configuration. I'm sure there are several ways to achieve this, but the suggested way with profiles should be the easiest. If I get everything right, it can be done as follows.
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% sure, but I remember that Behat merges the default profile with others, so hopefully you don't have to copy everything if that doesn't work, then try to define the complete profile.
Also, take a look at this comment , you can define which tags to include in each profile, which can be quite useful if you want it to only run certain tests on some browsers.
To run it, you specify a profile:
$ behat -p firefox $ behat -p chrome
source to share