Watir models everything in the DOM. So think something like this should work
b.uls.each do |ul|  ul.lis.each { |li| p li.text }end 

      From: "[email protected]" <[email protected]>
 To: Watir General <[email protected]> 
 Sent: Tuesday, January 3, 2017 2:59 PM
 Subject: [wtr-general] iterating LI through elements
   
Hello Folks,
I am trying to find syntax for express the following. 
I want to iterate across LI elements in a UL (unordered list)
I thought something like this would do it: 
  all_li_elements = browser.div(:id => 'topLevelMenu0').li
Maybe that's close?
Then I was hoping to iterate though them search for one:
  all_li_elements.each { |e| puts e.text } 
Or perhaps I would use the list of LI elements in an RSpec expect statement 
with an include matcher that specifies one in the list. 
I have used the following to see the text in an LI element:
menu_li_element = browser.div(:id => 'topLevelMenu0').li(:text => "Open New 
Document")

which returns a single LI element. And, I find the text itself here: 
puts menu_li_element.text"Open New Document"

If you know of some useful references to this kind of stuff on the Net, then 
please share the link or even a few keywords that might help me find it. 
Perhaps there are methods better suited?
-az



-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.
 
[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.


   

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to