On Saturday, June 29, 2013 10:29:28 AM UTC-7, Fred Cassirer wrote: > Hi, > > I have some page source that looks like: > > <div class="battery"> <ul class="battery-level-list" > data-battery-level="5.71535"> <li class="green">1</li> > <li class="green">1</li> <li > class="green">1</li> <li class="green">1</li> > </ul> </div> > > > I'm trying to get the value of 'data-battery-level' ... > > > I have tried a number of different things, but I can't seem to find how to > pick out the value. > > > b = Watir:Browser.new > > ... > > d = b.div :class => 'battery' > > d.text > > => "1\n1\n1\n1" > > >> d.ul > => #<Watir::UList:0x101696b88 located=false selector={:tag_name=>"ul"}> > > >> d.elements > => #<Watir::HTMLElementCollection:0x1016a7a50 @selector={}, > @parent=#<Watir::Div:0x..fe7cbadc7c located=true > selector={:class=>"battery", :tag_name=>"div"}>> > >> b.div(:class,"battery").li(:index,2).text > => "1" > >> b.div(:class,"battery-level-list") > => #<Watir::Div:0x10175b960 located=false > selector={:class=>"battery-level-list", :tag_name=>"div"}> > > I'm stumped ... > > Thanks in advance for any insight > -Fred >
The div is just an outer container, the ul (unordered list) tag inside the div is what has the attribute you want to get. So you want to do something like b.ul(:class => "battery-level-list").attribute_value("data-battery-level") -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- 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 watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.