“Action” Methods
click /^I click on "([^"]*)"$/
Click on an element based on given selector.
When I click on "button.showModal"
press /^(?:|I )press "([^"]*)"$/
Press a button element with string argument interpreted as (in order):
- CSS Selector
- Text of
<button>
elements - Value of
<input type="submit">
elements
When I press "button.register"
And I press "Register"
And I press "Submit"
follow /^I follow "([^"]*)"$/
Follow a link element with string argument interpreted as (in order):
- CSS Selector
- Text of
<a>
elements
When I follow "a[href='/about']"
hover /^I hover "([^"]*)" element$/
Hover an element with cursor (activate CSS :hover property).
When I hover "nav.menu" element
submit /^I submit "([^"]*)" form$/
Submits a form found by given selector. The submit command may also be applied to any element that is a descendant of a <form> element.
When I submit "form#register" form
“Assert DOM” Methods
html contains /^I should see "([^"]*)"$/
Assert page sources (with tags) contains the provided string.
Then I should see "Home Page"
html not contains /^I should not see "([^"]*)"$/
Assert page sources (with tags) not contains the provided string.
Then I should not see "Detail Page"
html match /^I should see text matching (.+)$/
Assert page sources (with tags) match with provided RegExp.
Then I should see text matching Post-\d+
html not match /^I should not see text matching (.+)$/
Assert page sources (with tags)does not match with provided RegExp.
Then I should not see text matching .+@.+
html element count /^I should see (\d+) "([^"]*)" elements?$/
Assert page contains X DOM-elements with the provided CSS Selector.
Then I should see 3 "section.post" elements
element contains /^(?:|I )should see "([^"]*)" in the "([^"]*)" element$/
Assert DOM-element(s) with the provided CSS Selector contains the provided text.
Then I should see "Home Page" in the "h1" element
element not contains /^(?:|I )should not see "([^"]*)" in the "([^"]*)" element$/
Assert DOM-element(s) with the provided CSS Selector do not contains the provided text.
Then I should not see "Post Detail Page" in the "h1" element
element visible /^I should see an? "([^"]*)" element$/
Assert if the selected DOM-element found by given selector is visible.
Then I should see an "h2.content-subhead" element
element not visible /^I should not see an? "([^"]*)" element$/
Assert if the selected DOM-element found by given selector is not visible.
Then I should not see an "h2.content-subhead" element
element exists /^the "([^"]*)" element should exist$/
Assert that at least one element exits matching given selector.
Then the "h2.content-subhead" element should exist
element not exists /^the "([^"]*)" element should not exist$/
Assert that no element exists matching given selector.
Then the "h2.content-subhead" element should not exist
“Assert Form” Methods
select value /^the "([^"]*)" current option contain "([^"]*)"$/
Assert the currently selected option of a select field contains provided text.
Then the "select[name='country']" current option contain "USA"
input value /^the "([^"]*)" field should contain "([^"]*)"$/
Assert if the input’s value of given selector contains provided text.
Then the "textarea[name='description']" field should contain "My text"
input not value /^the "([^"]*)" field should not contain "([^"]*)"$/
Assert if the input’s value of given selector do not contains provided text.
Then the "textarea[name='description']" field should not contain "My first name"
input enabled /^the "([^"]*)" field should be enabled$/
Assert that the input is enabled.
Then the "input[name='first_name']" field should be enabled
input disabled /^the "([^"]*)" field should be disabled$/
Assert that the input is disabled.
Then the "input[name='disabled_input']" field should be disabled
checkbox checked /^the "([^"]*)" checkbox should be checked$/
Assert that the checkbox is checked.
Then the "#checkbox-input" checkbox should be checked
checkbox unchecked /^the "([^"]*)" checkbox should not be checked$/
Assert that the checkbox is unchecked.
Then the "#checkbox-input" checkbox should not be checked
“Assert Url” Methods
on homepage /^I should be on (?:|the )homepage$/
Assert current URL pathname equals ‘/’.
Then I should be on the homepage
url /^(?:|I )should be on "([^"]*)"$/
Assert current URL pathname equals the given string.
Then I should be on "/post/1"
url match /^the url should match (.+)$/
Assert current URL pathname match against provided RegExp.
Then the url should match ^\/post\/\d+
url query match /^the url parameter should match (.+)$/
Assert current URL query string match against provided RegExp.
Then the url parameter should match ^\/post\/\d+
“Form” Methods
fill field /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ /^(?:|I )fill in "([^"]*)" with:$/
Send a sequence of key strokes to an element (clears value before). You can also use unicode characters like Left arrow or Back space. You’ll find all supported characters here. To do that, the value has to correspond to a key from the table.
Then I fill in "input[name='first_name']" with:
"""
My long multi-line text ...
"""
fill multiple /^(?:|I )fill in the following:$/
Fill multiples fields at once. Internally uses the above step.
When I fill in the following:
| input[name='first_name'] | John |
| input[name='last_name'] | Doe |
| textarea[name='description'] | Some text ... |
choose in select /^(?:|I )select "([^"]*)" from "([^"]*)"$/
Select option that display text matching the argument.
Then I select "France" from "select.country"
check /^(?:|I )check "([^"]*)"$/
Check the checkboxe with provided selector.
Then I check "#checkbox-input"
uncheck /^(?:|I )uncheck "([^"]*)"$/
Uncheck the checkboxe with provided selector.
Then I uncheck "#checkbox-input-next"
“Navigation” Methods
base url /^(?:|I )browse "([^"]*)"$/
Set driver’s baseUrl. Useful to use short path in subsequent navigation (ex: “/login”)
When I browse "http://127.0.0.1:3000/
homepage /^(?:|I )am on (?:|the )homepage$/
Navigate to homepage, ie: baseUrl + ‘/’
When I am on the homepage
browse /^(?:|I )am on "([^"]*)"$/
Browse given URL or path.
When I am on "/post/2"
reload /^(?:|I )reload the page$/
Reload the current page.
When I reload the page
back /^(?:|I )move backward one page$/
Navigate backwards in the browser history, if possible.
When I move backward one page
“Utility” Methods
screenshot /^I take a screenshot$/
Take a screenshot of the current viewport and save it at ./screenshot.png
Then I take a screenshot
viewport /^the viewport is (\d+)px width and (\d+)px height$/
Set browser viewport size, width and height in pixel. The default viewport is: { width: 1366, height: 768 } (most used screen resolution).
When the viewport is 360px width and 568px height
wait /^I wait (\d+) seconds?$/
Wait for X seconds.
Then I wait 10 seconds