How to click on link element with specific text using watir? -


i'm not able click on text link 'add' using watir:

page:

<div id="divadd" style="float: right">     <a onclick="switchview('2')" style="color: #1b56a7; cursor: pointer;">add</a> </div> 

watir code:

browser.link(:text =>"add").click 

exception:

unable locate element, using {:tag_name=>["a"], :text=>"add"} 

please me how handle this?

if page has lot of ajax , javascript going on, may have wait little bit client side code finish rendering page after has been loaded browser.

try this

browser.link(:text =>"add").when_present.click 

if not work, make sure item not in frame or something..

btw, if there more 1 link on page text 'add' may have specify container outside link lets identify link want. eg.

browser.div(id: => "divadd").link.when_present.click 

if


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -