-1

Please help with the code to click on text by referring to text1 in Behat.

text1 is a unique property name and I have to use this to click on link text.

<h3>
<span class="label label-default">text1</span>
<a class="btn btn-xs btn-success btn-style" href="link1">
<span class="icon glyphicon glyphicon-plus" aria-hidden="true"></span>
text
</a>
Michael Benjamin
  • 265,915
  • 79
  • 461
  • 583
  • This is for behat 2 http://stackoverflow.com/questions/37277333/mink-goutte-how-to-check-checkbox-without-attribute-in-goutte If you have behat 3 then you should have something similar, a find in your object and click after. You should click on the link using css like a[href*=link1] – lauda Sep 03 '16 at 07:07

3 Answers3

1

On your method (step method) Using a MinkContext object or directly in your FeatureContext:

$cssSelector = //the css value you want to click
$this->getSession()->getPage()->find('css'. $cssSelector)->click();

You can find your exactly cssselector value in chrome console in "Elements" tab, by clicking in your mouse right button -> Copy -> Copy Selector.

XorX
  • 168
  • 1
  • 2
  • 18
1

You can use the 'css' selector here to click 'text'. If the class = icon glyphicon glyphicon-plus, then try the code below:

$this->getSession->getPage()->find('css','.icon .glyphicon .glyphicon-plus)->click();

-1

Maybe you can try:

ElementInterface::findAll

Then loop for each node and compare both, the tag and the value with your key.

Good look.