Limit "should see a button" to actually visible elements

This commit is contained in:
Ingo Schommer 2013-06-07 15:45:15 +02:00
parent 17bca1db86
commit 7dfe5ccbd2

View File

@ -105,8 +105,12 @@ class CmsFormsContext extends BehatContext
public function iShouldSeeAButton($text)
{
$page = $this->getSession()->getPage();
$element = $page->find('named', array('link_or_button', "'$text'"));
assertNotNull($element, sprintf('%s button not found', $text));
$els = $page->findAll('named', array('link_or_button', "'$text'"));
$matchedEl = null;
foreach($els as $el) {
if($el->isVisible()) $matchedEl = $el;
}
assertNotNull($matchedEl, sprintf('%s button not found', $text));
}
/**
@ -115,8 +119,12 @@ class CmsFormsContext extends BehatContext
public function iShouldNotSeeAButton($text)
{
$page = $this->getSession()->getPage();
$element = $page->find('named', array('link_or_button', "'$text'"));
assertNull($element, sprintf('%s button found', $text));
$els = $page->findAll('named', array('link_or_button', "'$text'"));
$matchedEl = null;
foreach($els as $el) {
if($el->isVisible()) $matchedEl = $el;
}
assertNull($matchedEl, sprintf('%s button found', $text));
}
}