0

Is it possible for behat to find an element by class name to click on? It looks like only the following is searched for: id|name|title|alt|value

For example, how could you successfully identify this element to click on?

<a class="button medium round signup" href="http://link.com" data-reveal-id="signupModal">sometext</a>

Also here is a simple page with a button, that has an ID. How come the following does not access the button?

<button id="myBtn" type="button" onclick="myFunction()">Try it</button>

Given I am on "http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_button_form"
When I press "myBtn" 

Thanks

David
  • 11
  • 1
  • 4

2 Answers2

0

The button can not be accessed because it is contained in an iframe, you need to switch to that iframe to make the button available.

You can create steps to click on an element by any type of identifier (class included), or you can implement new step that requires css/xpath selectors.

Here you can find an example of a method to click by selector.

Community
  • 1
  • 1
lauda
  • 4,153
  • 2
  • 14
  • 28
0

The first HTML code is nothing but a HREF. Behat should be easily able to identify it by using the line below: Given I follow "sometext"

If the above doesn't work, you can simply use the CSS selector and click the element:

$locator = '.';

$this->getSession()->getPage()->find('css',$locator)->click();
Draken
  • 3,134
  • 13
  • 34
  • 54