diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 9ce09bd..ea5fe2f 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -421,6 +421,24 @@ JS; } } + /** + * Finds a named element. See {@link \Behat\Mink\Selector\NamedSelector} for ways to specify how to find + * the table. The easiest of these is adding a
element to the table in question. + * + * @Then /^I should see "([^"]*)" in the "([^"]*)" table$/ + */ + public function iShouldSeeInTheTable($value, $tableName) { + // Get table + $page = $this->getSession()->getPage(); + $table = $page->find('named', array('table', "$tableName")); + + if($table) { + assertContains($value, $table->getText(), "Couldn't find '$value' in the '$tableName' table"); + } else { + throw new \InvalidArgumentException("Couldn't find a table called '$tableName'"); + } + } + /** * Transforms relative time statements compatible with strtotime(). * Example: "time of 1 hour ago" might return "22:00:00" if its currently "23:00:00".