Last active
September 17, 2015 11:40
-
-
Save johnennewdeeson/e92bc6b76cd3eb74f14c to your computer and use it in GitHub Desktop.
Drupal Behat Step definition for clicking an operations link in a table where another cell in the same row contains a known value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @When I click :link_text in table row containing :text | |
*/ | |
public function iClickOperationLinkInTableRowWithText($link_text, $text) { | |
$session = $this->getSession(); | |
$el = $session->getPage()->find('xpath', "//td[contains(., '{$text}')]"); | |
if (empty($el)) { | |
throw new ExpectationException(t('No such text in table - @text', array( | |
'@text' => $text, | |
)), $session); | |
} | |
$tr = $el->getParent(); | |
$link = $tr->findLink($link_text); | |
if (empty($link)) { | |
throw new ExpectationException(t('No such link @link_text in row with @text', array( | |
'@link_text' => $link_text, | |
'@text' => $text, | |
)), $session); | |
} | |
$link->click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment