Download the PHP package ekino/behat-helpers without Composer
On this page you can find all versions of the php package ekino/behat-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ekino/behat-helpers
More information about ekino/behat-helpers
Files in ekino/behat-helpers
Package behat-helpers
Short Description Helpers for Behat
License MIT
Homepage https://github.com/ekino/behat-helpers
Informations about the package behat-helpers
Behat Helpers
This library provides some helpers over Behat.
This is a work in progress, so if you'd like something implemented please feel free to ask for it or contribute to help us!
Installation
Require it using Composer:
And use the helpers you need in your FeatureContext class.
BaseUrlTrait
Behat handles only one base URL to run the tests suites. In order to test a multisite-application, this trait allows you to inject a base URL by suite.
DebugTrait
This trait can be used for debug purposes. It captures both HTML and screenshot when a step fails, so you can see the page at this moment.
Note that it requires KernelDictionary
from behat/symfony2-extension.
You can also profile your tests by adding the tag behat_helpers_profile
on
the feature or scenario. You'll see the consumed memory and the execution time
for each scenario.
ExtraSessionTrait
This trait provides some helpers over the session.
Step | Regex |
---|---|
I wait for 2 seconds | /^I wait for (\d+) seconds?$/ |
I wait for "foo" element being visible for 2 seconds | /^I wait for "([^"]*)" element being visible for (\d+) seconds$/ |
I wait for "Foo" element being invisible for 2 seconds | /^I wait for "([^"]*)" element being invisible for (\d+) seconds$/ |
I scroll to 123 and 987 | /^I scroll to (\d+) and (\d+)?$/ |
I wait 3 seconds that page contains text "Foo" | /^I wait (\d+) seconds that page contains text "([^"]*)"$/ |
I wait 3 seconds that page not contains text "Bar" | /^I wait (\d+) seconds that page not contains text "([^"]*)"$/ |
I click on button containing "Foo" | /^I click on (?:link\|button) containing "(?P<text>[^"]*)"$/ |
ExtraWebAssertTrait
This trait provides some extra asserts.
Step | Regex |
---|---|
the "Foo" element should have attribute "Bar" | /^the "(?P<element>[^"]*)" element should have attribute "(?P<value>(?:[^"]\|\\")*)"$/ |
I click the "Foo" element | /^I click the "(?P<element>[^"]*)" element$/ |
I should see at least 2 "Bar" elements | /^(?:\|I )should see at least (?P<num>\d+) "(?P<element>[^"]*)" elements?$/ |
ReloadCookiesTrait
This trait aims to write small/simple scenarii and preserve execution time. To do so, the cookies are reloaded between the scenarii. This can be useful in case of a multistep form: the first scenario fills the first step and submits (here the cookies are saved), then the second scenario is executed (the cookies are reloaded so no need to do the previous step again) and fills the second step...etc.
You can add the tag behat_helpers_no_cache
to avoid cookies being saved/reloaded:
You can add the tag behat_helpers_reset_cache
to clear cookies previously saved:
Step | Regex |
---|---|
I fill the first step | /^I fill the first step$/ |
I fill the second step | /^I fill the second step$/ |
ReloadDatabaseTrait
This trait allows you to restore the database at the end of a scenario as it was before the scenario starts. It can be useful if a scenario alters the database, so the scenarii can be independent.
Of course, it can take a while with a big database.
For now, only MySQL is supported. It requires mysqldump
to be installed to
export the data, and doctrine/doctrine-bundle to re-import the dump.
Note that it requires KernelDictionary
from behat/symfony2-extension.
RouterAwareTrait
This helper uses the router from Symfony and so avoids hard-coded URL in your scenarii.
Note that it requires KernelDictionary
from behat/symfony2-extension.
If your route requires some parameters, you can provide them by separating them
to the route identifier with a ;
:
SonataAdminTrait
This trait integrates sonata-project/admin-bundle with some basics like interaction with menu, navigation bar, poping, select2... You can combined it with the ReloadCookiesTrait in order to login only once for instance, and with RouterAwareTrait to use route ids.
Note that it requires KernelDictionary
from behat/symfony2-extension.
Step | Regex |
---|---|
I open the menu "Foo" | /^I open the menu "([^"]*)"$/ |
I should see "Foo" action in navbar | /^I should see "([^"]*)" action in navbar$/ |
I should not see "Foo" action in navbar | /^I should not see "([^"]*)" action in navbar$/ |
I click on "Foo" action in navbar | /^I click on "([^"]*)" action in navbar$/ |
clicking on the "Foo" element should open a popin "Bar" | /^clicking on the "([^"]*)" element should open a popin "([^"]*)"$/ |
the popin "Foo" should be closed | /^the popin "([^"]*)" should be closed$/ |
the popin "Foo" should not be opened | /^the popin "([^"]*)" should not be opened$/ |
the popin "Foo" should be opened | /^the popin "([^"]*)" should be opened$/ |
I set the select2 field "Foo" to "Bar" | /^(?:\|I )set the select2 field "(?P<field>(?:[^"]\|\\")*)" to "(?P<textValues>(?:[^"]\|\\")*)"$/ |
I set the select2 value "Foo" for "Bar" | /^(?:\|I )set the select2 value "(?P<textValues>(?:[^"]\|\\")*)" for "(?P<field>(?:[^"]\|\\")*)"$/ |
SonataPageAdminTrait
This trait integrates sonata-project/page-bundle with some basics like interaction with container, block... You can combined it with the RouterAwareTrait to use route ids.
Step | Regex |
---|---|
I open the container by text "Content" | /^I open the container "([^"]*)"$/ |
I add the block "Simple text" with the name "Foo" | /^I add the block "([^"]*)" with the name "([^"]*)"$/ |
I go to the tab "English" of the block "Foo" | /^I go to the tab "([^"]*)" of the block "([^"]*)"$/ |
I should see 6 blocks | /^I should see (\d+) blocks$/ |
I open the block "Foo" | /^I open the block "([^"]*)"$/ |
I submit the block "Foo" | /^I submit the block "([^"]*)"$/ |
I delete the block "Foo" | /^I delete the block "([^"]*)"$/ |
I rename the block "Foo" with "Bar" | /^I rename the block "([^"]*)" with "([^"]*)"$/ |
The block "Foo" should be opened | /^The block "([^"]*)" should be opened$/ |
The block "Foo" should be closed | /^The block "([^"]*)" should be closed$/ |
All versions of behat-helpers with dependencies
behat/mink-extension Version ^2.3
behat/mink-selenium2-driver Version ^1.3
behat/symfony2-extension Version ^2.1
cocur/slugify Version ^3.1 || ^4.0
symfony/stopwatch Version ^2.8 || ^3.0 || ^4.0