try ie.elements_by_xpath(//d...@class='details']).length - Angrez
On Thu, Feb 5, 2009 at 10:04 AM, Jason <freezingki...@gmail.com> wrote: > > I've got anywhere from 1 to 10 <div> elements on my page with the same > class. > > <div class="details"> > > I want a robust and quick way of determining how many, or iterating > through each of these divs. > > divs.find_all does the job, but it's rather slow because it appears to > be iterating through EVERY <div> on my page (300+) and then attempting > to match these to the class, i.e. > > $ie.divs.find_all{|dv|/details/.match(dv.class_name)}.length > > A little bit slow. > > Alternatively I thought of using :index until I resulted in an error, > i.e. > > for i in 1..10 (until an error occurs) > $ie.div(:class=>"details", :index=>i) > end > > But this seems a little messy. > > Any better suggestions? Something simple I'm missing? > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---