In webdriver singular methods return a singe (the first) element of that type, while plural methods return a list of all elements.
.checkbox returns one .checkboxes returns a list/collection On Mon, 7 Nov 2011 08:36:56 -0800 (PST), Joe Fl wrote: > Hi, > > I am still having problems with checkboxes. I need to get the id from > the html source for group of checkboxes under certain header sections. > > HTML: > > * > > COMMUNITY FEATURES > > Guided Discussions > > Each section could 1 to many checkboxes showing. > > I have tried the following: > chck_bx = $browser.div(:class,"mod simple your- > subscriptions").div(:class,"bd").ul(:class,"items").li(:class,'item > community-features').div(:class,'line form').checkbox > > chck_bx.each do|cb| > puts cb.id > end > > and it failed: > NoMethodError: undefined method `each' for # > from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir- > webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:295:in > `method_missing' > from (irb):169 > > I would appreciate any help with this. > > Thank you, > Joe > > On Oct 12, 4:07 pm, Chuck van der Lindenwrote: > >> On Oct 12, 12:09 pm, Joe Fleckwrote: >> >>> Hi Chuck, >> >>> Thank you for help. >> lists = $browser.div(:class,'add-themes').lis lists.each do |li| >> >>> x; width:100%"> put >> .text >> >>> yle="padding-left:5px; border-left:#101 >> ; margin-left:5px; width:100%"> puts davalue Thank you very much this is huge win. >> ill seem to be doing a few rather round-about things in there. If the structure of the page i >> >>> o have inside each of them the label and >> . You should not need to get the text from the label, then use that to find the label, the label's parent, >> >>> he trouble of creating v >> so you can feed them to puts? This makes for far simpler and easier to read code IMHO The loop then becomes >> >>> .text if it's important to verify that the label exists. &nbs >> eckbox.value end Also, unless you need to get the count of how many list items are pres >> >>> > > -- Before posting, please read http://watir.com/support [1]. In short: search before you ask, be nice. watir-general@googlegroups.com [2] http://groups.google.com/group/watir-general [3] watir-general+unsubscr...@googlegroups.com [4] Links: ------ [1] http://watir.com/support [2] mailto:watir-general@googlegroups.com [3] http://groups.google.com/group/watir-general [4] mailto:watir-general+unsubscr...@googlegroups.com -- 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