3
votes

I am using the WATIR-Ruby for my Web Application. I am currently facing an issue clicking on a text element that is populated dynamically when a search bar is partially/completely filled with text. The code is unable to identify the element I am trying to click.

http://i.stack.imgur.com/q5Hmv.png

I am unable to click on any of the results obtained from the search.

Here is the HTML source :

<div class="results" style="display: block;">
 <ul>
    <li nodeid="111">Profile_Child</li>
    <li nodeid="222">Profile_Grandchild</li>
    <li nodeid="333">Rest_Child2</li>
    <li nodeid="444">rest_grandchild2</li>
 </ul>
</div>

How would I code for clicking these elements in Ruby/Watir?

1
clicking means what ? This is not a drop down list. Althoug it is a good question +1.Arup Rakshit
It is not a dropdown .You will get a clear idea if you look at the image link in my question. There is an empty search bar where we provide our text. Based on the partial/complete text entered in the search bar a result list is displayed with elements that can be clicked. Clicking on the data takes me to another page in the applicationuser3231104
Yes.. I got that point by seeing the image.. :)Arup Rakshit

1 Answers

2
votes

This should work:

@browser.div(:class => "results").ul.li(:text => "Profile_Child").click