mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Click first visable link
This commit is contained in:
parent
c456dbac5d
commit
f5957a0586
@ -312,4 +312,24 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwritten to click the first *visable* link the DOM.
|
||||
*/
|
||||
public function clickLink($link)
|
||||
{
|
||||
$link = $this->fixStepArgument($link);
|
||||
$links = $this->getSession()->getPage()->findAll('named', array(
|
||||
'link', $this->getSession()->getSelectorsHandler()->xpathLiteral($link)
|
||||
));
|
||||
if($links) foreach($links as $l) {
|
||||
if($l->isVisible()) {
|
||||
$l->click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new ElementNotFoundException(
|
||||
$this->getSession(), 'link', 'id|name|label|value', $link
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user