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:
<li class="item community-features">
<h2>Community Features</h2>
<div class="line form">
<input id="109" class="unit content-feed-unsubscribe checkbox mrm"
type="checkbox" value="content-feed-109" name="content_feed_Guided
Discussions" data-subscription-url="/content_feeds/109/subscribe?
channel_id=57" data-content-feed-id="109" checked="">
<label class="unit label-for-checkbox" for="109">Guided Discussions</
label>
</div>
</li>

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 #<Watir::CheckBox:
0x104229b60>
        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 Linden <[email protected]> wrote:
> On Oct 12, 12:09 pm, Joe Fleck <[email protected]> wrote:
>
>
>
>
>
>
>
>
>
> > Hi Chuck,
>
> > Thank you for help.
>
> > I used the parent.
>
> > lists = $browser.div(:class,'add-themes').lis
>
> >       numListStr = lists.length
>
> >       lists.each do |li|
>
> >         puts chckbx = li.text
>
> >         davalue = $browser.label(:text, chckbx).parent.checkbox.value
>
> >         puts davalue
>
> >       end
>
> > I just want a specific section of checkboxes and there are more within the
> > window.
>
> > Thank you very much this is huge win.
>
> IMHO you still seem to be doing a few rather round-about things in
> there.
>
> If the structure of the page is a list item, inside which is a label
> and acheckbox, then when you get the collection of list items, you
> also have inside each of them the label and thecheckbox..  You should
> not need to get the text from the label, then use that to find the
> label, the label's parent, and thecheckboxthat is inside the
> parent.  If you are not going to use them inside the loop, why go to
> the trouble of creating variables just so you can feed them to puts?
>
> This makes for far simpler and easier to read code IMHO
>
> The loop then becomes
>
>       lists.each do |li|
>
>         puts li.text     # or li.label.text if it's important to
> verify that the label exists.
>         puts li.checkbox.value
>
>       end
>
> Also, unless you need to get the count of how many list items are
> present, the first three lines could be done simply as:
>
> $browser.div(:class,'add-themes').lis.each do |li|

-- 
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]

Reply via email to