Add Behat step to click on a row in the first GridField table.

This commit is contained in:
Mateusz Uzdowski 2014-02-07 15:37:24 +13:00
parent 9bfd1d3a5d
commit e91f10b0ab

View File

@ -124,6 +124,22 @@ class CmsUiContext extends BehatContext {
return $table_element;
}
/**
* Finds the first visible GridField table.
*/
protected function getFirstGridFieldTable() {
$page = $this->getSession()->getPage();
$tableElements = $page->findAll('css', '.ss-gridfield-table');
assertNotNull($tableElements, 'Table elements not found');
// Return first found table.
foreach($tableElements as $table) {
if($table->isVisible()) return $table;
}
assertNotNull(null, 'First visible table element not found');
}
/**
* @Given /^I should see a "([^"]*)" button in CMS Content Toolbar$/
*/
@ -233,6 +249,20 @@ class CmsUiContext extends BehatContext {
$element->click();
}
/**
* Clicks on a row in the first found visible GridField table.
* Example: I click on "New Zealand" in the table
*
* @Given /^I click on "([^"]*)" in the table$/
*/
public function iClickOnInTheFirstTable($text) {
$table_element = $this->getFirstGridFieldTable();
$element = $table_element->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
assertNotNull($element, sprintf('Element containing `%s` not found', $text));
$element->click();
}
/**
* @Then /^I can see the preview panel$/
*/