From 7dfe5ccbd283d7146743a155838f0fbf6c7d808c Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 7 Jun 2013 15:45:15 +0200 Subject: [PATCH] Limit "should see a button" to actually visible elements --- .../Framework/Test/Behaviour/CmsFormsContext.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php index a9721acee..1907a4b8d 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsFormsContext.php @@ -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)); } }