-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to define in which browser types to run tests #38
Comments
The point is - Mink is session oriented. One session is in relation with driver and, as consequense, with browser 1-to-1. So, you really need to just create a new sessions with different browser configurations. To do this, override After that, you'll be able to switch to interesting session with: @mink:SESSION_NAME
Scenario: ...
... For example: <?php # .../FeatureContext.php
...
protected function registerSessions(Mink $mink)
{
parent::registerSessions($mink);
$mink->registerSession('chrome', new Session(
$this->initSahiDriver('chrome', $this->getParameter('sahi'))
));
}
... @mink:chrome
Scenario: JS scenario to be runned inside chrome browser
... By the way, this: @mink:sahi
Scenario: ...
... will do exactly the same as this: @javascript
Scenario: ...
... ;-) |
Does this allow to do things like @mink:firefox @mink:chrome
Scenario: ... Sort of what @dataProvider is doing for phpunit, but for sessions? |
Nope. Default scenario steps always run against single default Mink session. And with this So, your This |
What do you think about adding a feature that allows to run the same scenario against more than one session? For headless browsers that doesn't matter so much, but if I run a scenario in a Sahi session, then I likely want that scenario to pass in all configured browsers (Firefox, Chrome, IE, etc.). I could copy/paste the scenario and apply different sessions, but then I get potentially many scenarios and something like @sessionProvider would be a bit easier. |
Yeah, i've got ya. You can do it quite easily with Scenario Outlines for example: Scenario Outline: Scenario to be runned against different browsers
Given I use "<browser>" browser
...
Examples:
| browser |
| firefox |
| chrome | The only thing left is to implement |
This problem is solved properly with Behat Profiles. With profiles, you can provide system-wide configuration with filters like this: firefox:
filters:
tags: '@javascript&&~@chrome'
context:
parameters: { browser: firefox }
chrome:
filters:
tags: '@javascript&&@chrome'
context:
parameters: { browser: chrome } With such configuration:
will run all scenarios with tag
will run all scenarios with both So, calling two this commands:
Will run scenarios in both browsers, providing useful output. The problem is, there's no profiles in BehatBundle. Maybe we should add them... What do you think? |
👍 for profiles in BehatBundle |
Hello everyone. This issue is 10 months age, so maybe it is why i can't make my Behat run tests in different from Chrome browser (why not firefox, i don't really know). |
@iamexe as pointed 10 months ago by @everzet in his latest comment, the answer is to use behat profiles, and launching the behat features once for each browser you want to test. |
You say if I have behat 2.4 (I have 2.3.3) I need just to add firefox profile to behat.yml like this: |
yes, and it works in Behat 2.3 standalone too (but not when using Behat 2.3 through BehatBundle) |
Thanks, everything works fine |
It would be nice if you could define on a scenario basis which browser types to run the test in (if it's a test annotated with @javascript). Let's say I want to generally run all scenarios in chrome and firefox, but certain scenarios I only want to run in firefox.
Right now, it seems like I can only configure this globally, and only a single browser type.
The text was updated successfully, but these errors were encountered: