-
-
Save jigante/06d19df03ca7eb78e6a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
// ... | |
class FeatureContext extends MinkContext | |
{ | |
/** | |
* Looks for a table, then looks for a row that contains the given text. | |
* Once it finds the right row, it clicks a link in that row. | |
* | |
* Really handy when you have a generic "Edit" link on each row of | |
* a table, and you want to click a specific one (e.g. the "Edit" link | |
* in the row that contains "Item #2") | |
* | |
* @When /^I follow "(?P<link>(?:[^"]|\\")*)" on the row containing "(?P<text>(?:[^"]|\\")*)"$/ | |
*/ | |
public function iClicknOTheRowContaining($linkName, $rowText) | |
{ | |
/** @var $row \Behat\Mink\Element\NodeElement */ | |
$row = $this->getSession()->getPage()->find('css', sprintf('table tr:contains("%s")', $rowText)); | |
if (!$row) { | |
throw new \Exception(sprintf('Cannot find any row on the page containing the text "%s"', $rowText)); | |
} | |
$row->clickLink($linkName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment