Watir/Ruby : How to click on a text in dropdown in Ruby/Watir

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.

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

Here is the HTML source :

  • Profile_Child
  • Profile_Grandchild
  • Rest_Child2
  • rest_grandchild2
How would I code for clicking these elements in Ruby/Watir?

These work:

b.li(:text => ‘Profile_Child’).flash
b.lis.each &:flash

Does it work if you do it in irb? If so, then you might need to wait for
the elements to appear.

You can try using waits and :xpath locator. You might similar examples
in
Watir Recipes book: https://leanpub.com/watir_recipes.