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 a checkbox, then when you get the collection of list items, you
also have inside each of them the label and the checkbox..  You should
not need to get the text from the label, then use that to find the
label, the label's parent, and the checkbox that 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