diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 71fe35d..33555e8 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -267,10 +267,13 @@ JS; public function stepIPressTheButton($button) { $page = $this->getSession()->getPage(); - - $buttonElement = $page->find('named', array('link_or_button', "'$button'")); - assertNotNull($buttonElement, sprintf('%s button not found', $button)); - $buttonElement->click(); + $els = $page->findAll('named', array('link_or_button', "'$button'")); + $matchedEl = null; + foreach($els as $el) { + if($el->isVisible()) $matchedEl = $el; + } + assertNotNull($matchedEl, sprintf('%s button not found', $button)); + $matchedEl->click(); } /**