mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
consolidate table check by specified id, name, value, title and so on
This commit is contained in:
parent
27a381f4e0
commit
0bbd00cf66
@ -676,4 +676,24 @@ JS;
|
|||||||
$session->getDriver()->click($radioButton->getXPath());
|
$session->getDriver()->click($radioButton->getXPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a <table> element by id, name, title, caption, style or value. See {@link \Behat\Mink\Selector\NamedSelector} for ways to specify how to find
|
||||||
|
* the table. The easiest of these is adding a <caption> element to the table in question.
|
||||||
|
*
|
||||||
|
* @Then /^the table "([^"]*)" should contain "([^"]*)"$/
|
||||||
|
*/
|
||||||
|
public function theTableShouldContain($locator, $value) {
|
||||||
|
// Get table
|
||||||
|
$page = $this->getSession()->getPage();
|
||||||
|
$table = $page->find('xpath',
|
||||||
|
$this->getSession()->getSelectorsHandler()->selectorToXpath("xpath", ".//table[(./@id = '$locator' or"
|
||||||
|
. " ./@name = '$locator' or contains(./@title, '$locator') or contains(./@caption, '$locator') or"
|
||||||
|
. " contains(./@value, '$locator') or ./@class = '$locator' or ./@style = '$locator')]")
|
||||||
|
);
|
||||||
|
if($table) {
|
||||||
|
assertContains($value, $table->getText(), "Couldn't find '$value' in the '$locator' table");
|
||||||
|
} else {
|
||||||
|
throw new \InvalidArgumentException("Couldn't find a table called '$locator'");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user