0
votes

I desire to use watir webdriver to click on a link on a webpage. If I use firebug to find the unique selector - I obtain the following:

new_login > div:nth-child(6) > button:nth-child(1)

How can I select and click this button using watir-webdriver?

1

1 Answers

2
votes

Clicking a direct translation of your xpath would be:

browser.element(:id => 'new_login').div(:index => 5).button.click

Depending on the actual html, you may be able to simplify it. For example, if there is only one button in the new_login element, you could just do:

browser.element(:id => 'new_login').button.click

The fewer things you need to locate the button, the more robust and maintainable your script will be.