Skip to content

Instantly share code, notes, and snippets.

@ccamara
Created December 3, 2014 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccamara/d00183a8361efd3df198 to your computer and use it in GitHub Desktop.
Save ccamara/d00183a8361efd3df198 to your computer and use it in GitHub Desktop.
Behat available step definitions with drupal extension Behat available step definitions with drupal extension
Behat available step definitions with drupal extension
Given /^(?:that I|I) am at "(?P[^"]*)"$/
- Visit a given path, and additionally check for HTTP response code 200.
# FeatureContext::assertAtPath()
When /^I visit "(?P[^"]*)"$/
# FeatureContext::assertVisit()
When /^I click "(?P<link>[^"]*)"$/
# FeatureContext::assertClick()
Given /^for "(?P<field>[^"]*)" I enter "(?P<value>[^"]*)"$/
# FeatureContext::assertEnterField()
Given /^I enter "(?P<value>[^"]*)" for "(?P<field>[^"]*)"$/
# FeatureContext::assertEnterField()
Given /^I wait for AJAX to finish$/
- Wait for AJAX to finish.
# FeatureContext::iWaitForAjaxToFinish()
When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)"$/
- Presses button with specified id|name|title|alt|value.
# FeatureContext::pressButton()
When /^(?:|I )press the "(?P<button>[^"]*)" button$/
- Presses button with specified id|name|title|alt|value.
# FeatureContext::pressButton()
Given /^(?:|I )press the "([^"]*)" key in the "([^"]*)" field$/
# FeatureContext::pressKey()
Then /^I should see the link "(?P<link>[^"]*)"$/
# FeatureContext::assertLinkVisible()
Then /^I should not see the link "(?P<link>[^"]*)"$/
# FeatureContext::assertNotLinkVisible()
Then /^I (?:|should )see the heading "(?P<heading>[^"]*)"$/
# FeatureContext::assertHeading()
Then /^I (?:|should )not see the heading "(?P<heading>[^"]*)"$/
# FeatureContext::assertNotHeading()
Then /^I should see the heading "(?P<heading>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
- Find a heading in a specific region.
# FeatureContext::assertRegionHeading()
Then /^I should see the "(?P<heading>[^"]*)" heading in the "(?P<region>[^"]*)"(?:| region)$/
- Find a heading in a specific region.
# FeatureContext::assertRegionHeading()
When /^I (?:follow|click) "(?P<link>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
# FeatureContext::assertRegionLinkFollow()
Then /^I should see the link "(?P<link>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
# FeatureContext::assertLinkRegion()
Then /^I should not see the link "(?P<link>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
# FeatureContext::assertNotLinkRegion()
Then /^I should see (?:the text |)"(?P<text>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
# FeatureContext::assertRegionText()
Then /^I should not see (?:the text |)"(?P<text>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
# FeatureContext::assertNotRegionText()
Given /^I press "(?P<button>[^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
- Checks, if a button with id|name|title|alt|value exists or not and pressess the same
# FeatureContext::assertRegionPressButton()
Given /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)" in the "(?P<region>[^"]*)"(?:| region)$/
- Fills in a form field with id|name|title|alt|value in the specified region.
# FeatureContext::regionFillField()
Given /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" in the "(?P<region>[^"]*)"(?:| region)$/
- Fills in a form field with id|name|title|alt|value in the specified region.
# FeatureContext::regionFillField()
Then /^(?:I|I should) see the text "(?P<text>[^"]*)"$/
# FeatureContext::assertTextVisible()
Then /^I should not see the text "(?P<text>[^"]*)"$/
# FeatureContext::assertNotTextVisible()
Then /^I should get a "(?P<code>[^"]*)" HTTP response$/
# FeatureContext::assertHttpResponse()
Then /^I should not get a "(?P<code>[^"]*)" HTTP response$/
# FeatureContext::assertNotHttpResponse()
Given /^I check the box "(?P<checkbox>[^"]*)"$/
# FeatureContext::assertCheckBox()
Given /^I uncheck the box "(?P<checkbox>[^"]*)"$/
# FeatureContext::assertUncheckBox()
When /^I select the radio button "(?P<label>[^"]*)" with the id "(?P<id>[^"]*)"$/
# FeatureContext::assertSelectRadioById()
When /^I select the radio button "(?P<label>[^"]*)"$/
# FeatureContext::assertSelectRadioById()
Given /^I am an anonymous user$/
# FeatureContext::assertAnonymousUser()
Given /^I am not logged in$/
# FeatureContext::assertAnonymousUser()
Given /^I am logged in as a user with the "(?P<roles>[^"]*)" role(?:|s)$/
- Creates and authenticates a user with the given role(s) via Drush.
# FeatureContext::assertAuthenticatedByRole()
Given /^I am logged in as "(?P<name>[^"]*)"$/
# FeatureContext::assertLoggedInByName()
Given /^I am logged in as a user with the "(?P<permission>[^"]*)" permission(?:|s)$/
# FeatureContext::assertLoggedInWithPermissions()
Then /^I should see the text "(?P<text>[^"]*)" in the "(?P<row_text>[^"]*)" row$/
- Find text in a table row containing given text.
# FeatureContext::assertTextInTableRow()
Given /^I click "(?P<link>[^"]*)" in the "(?P<row_text>[^"]*)" row$/
- Attempts to find a link in a table row containing giving text. This is for
# FeatureContext::assertClickInTableRow()
Given /^the cache has been cleared$/
# FeatureContext::assertCacheClear()
Given /^I run cron$/
# FeatureContext::assertCron()
Given /^I am viewing (?:a|an) "(?P<type>[^"]*)" node with the title "(?P<title>[^"]*)"$/
# FeatureContext::createNode()
Given /^(?:a|an) "(?P<type>[^"]*)" node with the title "(?P<title>[^"]*)"$/
# FeatureContext::createNode()
Given /^I am viewing my "(?P<type>[^"]*)" node with the title "(?P<title>[^"]*)"$/
# FeatureContext::createMyNode()
Given /^"(?P<type>[^"]*)" nodes:$/
# FeatureContext::createNodes()
Given /^I am viewing (?:a|an) "(?P<type>[^"]*)" node:$/
# FeatureContext::assertViewingNode()
Then /^I should be able to edit (?:a|an) "([^"]*)" node$/
- Asserts that a given node type is editable.
# FeatureContext::assertEditNodeOfType()
Given /^I am viewing (?:a|an) "(?P<vocabulary>[^"]*)" term with the name "(?P<name>[^"]*)"$/
# FeatureContext::createTerm()
Given /^(?:a|an) "(?P<vocabulary>[^"]*)" term with the name "(?P<name>[^"]*)"$/
# FeatureContext::createTerm()
Given /^users:$/
- Creates multiple users.
# FeatureContext::createUsers()
Given /^"(?P<vocabulary>[^"]*)" terms:$/
# FeatureContext::createTerms()
Then /^I should see the error message(?:| containing) "([^"]*)"$/
- Checks if the current page contains the given error message
# FeatureContext::assertErrorVisible()
Then /^I should see the following <error messages>$/
- Checks if the current page contains the given set of error messages
# FeatureContext::assertMultipleErrors()
Given /^I should not see the error message(?:| containing) "([^"]*)"$/
- Checks if the current page does not contain the given error message
# FeatureContext::assertNotErrorVisible()
Then /^I should not see the following <error messages>$/
- Checks if the current page does not contain the given set error messages
# FeatureContext::assertNotMultipleErrors()
Then /^I should see the success message(?:| containing) "([^"]*)"$/
- Checks if the current page contains the given success message
# FeatureContext::assertSuccessMessage()
Then /^I should see the following <success messages>$/
- Checks if the current page contains the given set of success messages
# FeatureContext::assertMultipleSuccessMessage()
Given /^I should not see the success message(?:| containing) "([^"]*)"$/
- Checks if the current page does not contain the given set of success message
# FeatureContext::assertNotSuccessMessage()
Then /^I should not see the following <success messages>$/
- Checks if the current page does not contain the given set of success messages
# FeatureContext::assertNotMultipleSuccessMessage()
Then /^I should see the warning message(?:| containing) "([^"]*)"$/
- Checks if the current page contains the given warning message
# FeatureContext::assertWarningMessage()
Then /^I should see the following <warning messages>$/
- Checks if the current page contains the given set of warning messages
# FeatureContext::assertMultipleWarningMessage()
Given /^I should not see the warning message(?:| containing) "([^"]*)"$/
- Checks if the current page does not contain the given set of warning message
# FeatureContext::assertNotWarningMessage()
Then /^I should not see the following <warning messages>$/
- Checks if the current page does not contain the given set of warning messages
# FeatureContext::assertNotMultipleWarningMessage()
Then /^I should see the message(?:| containing) "([^"]*)"$/
- Checks if the current page contain the given message
# FeatureContext::assertMessage()
Then /^I should not see the message(?:| containing) "([^"]*)"$/
- Checks if the current page does not contain the given message
# FeatureContext::assertNotMessage()
Given /^I run drush "(?P<command>[^"]*)"$/
# FeatureContext::assertDrushCommand()
Given /^I run drush "(?P<command>[^"]*)" "(?P<arguments>(?:[^"]|\\")*)"$/
# FeatureContext::assertDrushCommandWithArgument()
Then /^drush output should contain "(?P<output>(?:[^"]|\\")*)"$/
# FeatureContext::assertDrushOutput()
Then /^drush output should not contain "(?P<output>(?:[^"]|\\")*)"$/
# FeatureContext::drushOutputShouldNotContain()
Then /^print last drush output$/
# FeatureContext::printLastDrushOutput()
Then /^(?:|I )break$/
- Pauses the scenario until the user presses a key. Useful when debugging a scenario.
# FeatureContext::iPutABreakpoint()
Given /^(?:|I )am on (?:|the )homepage$/
- Opens homepage.
# FeatureContext::iAmOnHomepage()
When /^(?:|I )go to (?:|the )homepage$/
- Opens homepage.
# FeatureContext::iAmOnHomepage()
Given /^(?:|I )am on "(?P<page>[^"]+)"$/
- Opens specified page.
# FeatureContext::visit()
When /^(?:|I )go to "(?P<page>[^"]+)"$/
- Opens specified page.
# FeatureContext::visit()
When /^(?:|I )reload the page$/
- Reloads current page.
# FeatureContext::reload()
When /^(?:|I )move backward one page$/
- Moves backward one page in history.
# FeatureContext::back()
When /^(?:|I )move forward one page$/
- Moves forward one page in history
# FeatureContext::forward()
When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)"$/
- Clicks link with specified id|title|alt|text.
# FeatureContext::clickLink()
When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)"$/
- Fills in form field with specified id|name|label|value.
# FeatureContext::fillField()
When /^(?:|I )fill in "(?P<field>(?:[^"]|\\")*)" with:$/
- Fills in form field with specified id|name|label|value.
# FeatureContext::fillField()
When /^(?:|I )fill in "(?P<value>(?:[^"]|\\")*)" for "(?P<field>(?:[^"]|\\")*)"$/
- Fills in form field with specified id|name|label|value.
# FeatureContext::fillField()
When /^(?:|I )fill in the following:$/
- Fills in form fields with provided table.
# FeatureContext::fillFields()
When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
- Selects option in select field with specified id|name|label|value.
# FeatureContext::selectOption()
When /^(?:|I )additionally select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
- Selects additional option in select field with specified id|name|label|value.
# FeatureContext::additionallySelectOption()
When /^(?:|I )check "(?P<option>(?:[^"]|\\")*)"$/
- Checks checkbox with specified id|name|label|value.
# FeatureContext::checkOption()
When /^(?:|I )uncheck "(?P<option>(?:[^"]|\\")*)"$/
- Unchecks checkbox with specified id|name|label|value.
# FeatureContext::uncheckOption()
When /^(?:|I )attach the file "(?P[^"]*)" to "(?P<field>(?:[^"]|\\")*)"$/
- Attaches file to field with specified id|name|label|value.
# FeatureContext::attachFileToField()
Then /^(?:|I )should be on "(?P<page>[^"]+)"$/
- Checks, that current page PATH is equal to specified.
# FeatureContext::assertPageAddress()
Then /^(?:|I )should be on (?:|the )homepage$/
- Checks, that current page is the homepage.
# FeatureContext::assertHomepage()
Then /^the (?i)url(?-i) should match (?P<pattern>"(?:[^"]|\\")*")$/
- Checks, that current page PATH matches regular expression.
# FeatureContext::assertUrlRegExp()
Then /^the response status code should be (?P<code>\d+)$/
- Checks, that current page response status is equal to specified.
# FeatureContext::assertResponseStatus()
Then /^the response status code should not be (?P<code>\d+)$/
- Checks, that current page response status is not equal to specified.
# FeatureContext::assertResponseStatusIsNot()
Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)"$/
- Checks, that page contains specified text.
# FeatureContext::assertPageContainsText()
Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)"$/
- Checks, that page doesn't contain specified text.
# FeatureContext::assertPageNotContainsText()
Then /^(?:|I )should see text matching (?P<pattern>"(?:[^"]|\\")*")$/
- Checks, that page contains text matching specified pattern.
# FeatureContext::assertPageMatchesText()
Then /^(?:|I )should not see text matching (?P<pattern>"(?:[^"]|\\")*")$/
- Checks, that page doesn't contain text matching specified pattern.
# FeatureContext::assertPageNotMatchesText()
Then /^the response should contain "(?P<text>(?:[^"]|\\")*)"$/
- Checks, that HTML response contains specified string.
# FeatureContext::assertResponseContains()
Then /^the response should not contain "(?P<text>(?:[^"]|\\")*)"$/
- Checks, that HTML response doesn't contain specified string.
# FeatureContext::assertResponseNotContains()
Then /^(?:|I )should see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
- Checks, that element with specified CSS contains specified text.
# FeatureContext::assertElementContainsText()
Then /^(?:|I )should not see "(?P<text>(?:[^"]|\\")*)" in the "(?P<element>[^"]*)" element$/
- Checks, that element with specified CSS doesn't contain specified text.
# FeatureContext::assertElementNotContainsText()
Then /^the "(?P<element>[^"]*)" element should contain "(?P<value>(?:[^"]|\\")*)"$/
- Checks, that element with specified CSS contains specified HTML.
# FeatureContext::assertElementContains()
Then /^the "(?P<element>[^"]*)" element should not contain "(?P<value>(?:[^"]|\\")*)"$/
- Checks, that element with specified CSS doesn't contain specified HTML.
# FeatureContext::assertElementNotContains()
Then /^(?:|I )should see an? "(?P<element>[^"]*)" element$/
- Checks, that element with specified CSS exists on page.
# FeatureContext::assertElementOnPage()
Then /^(?:|I )should not see an? "(?P<element>[^"]*)" element$/
- Checks, that element with specified CSS doesn't exist on page.
# FeatureContext::assertElementNotOnPage()
Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
- Checks, that form field with specified id|name|label|value has specified value.
# FeatureContext::assertFieldContains()
Then /^the "(?P<field>(?:[^"]|\\")*)" field should not contain "(?P<value>(?:[^"]|\\")*)"$/
- Checks, that form field with specified id|name|label|value doesn't have specified value.
# FeatureContext::assertFieldNotContains()
Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should be checked$/
- Checks, that checkbox with specified in|name|label|value is checked.
# FeatureContext::assertCheckboxChecked()
Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" (?:is|should be) checked$/
- Checks, that checkbox with specified in|name|label|value is checked.
# FeatureContext::assertCheckboxChecked()
Then /^the "(?P<checkbox>(?:[^"]|\\")*)" checkbox should not be checked$/
- Checks, that checkbox with specified in|name|label|value is unchecked.
# FeatureContext::assertCheckboxNotChecked()
Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" should (?:be unchecked|not be checked)$/
- Checks, that checkbox with specified in|name|label|value is unchecked.
# FeatureContext::assertCheckboxNotChecked()
Then /^the checkbox "(?P<checkbox>(?:[^"]|\\")*)" is (?:unchecked|not checked)$/
- Checks, that checkbox with specified in|name|label|value is unchecked.
# FeatureContext::assertCheckboxNotChecked()
Then /^(?:|I )should see (?P<num>\d+) "(?P<element>[^"]*)" elements?$/
- Checks, that (?P<num>\d+) CSS elements exist on the page
# FeatureContext::assertNumElements()
Then /^print current URL$/
- Prints current URL to console.
# FeatureContext::printCurrentUrl()
Then /^print last response$/
- Prints last response to console.
# FeatureContext::printLastResponse()
Then /^show last response$/
- Opens last response content in browser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment