On 5/2/07, Jason & Aneta <[EMAIL PROTECTED]> wrote:

Hey all,

Using the 1.5.1.1158 gem and enjoying the class support.

Within my web page, I have the following, with 3 <div> nested inside
the main "content" <div>.

<div class="content">
   <div class="contentItem">
   </div>
   <div class="contentItem">
   </div>
   <div class="contentItem">
   </div>
</div>

How do I retrieve / act within the nth instance, i.e. the 1st, 2nd or
3rd of these "contentItem" divs?


Hi Jason,

divs (and many other elements) can be accessed by :index. For example:

ie.div(:index,2)                    # access the second div on the page

You can also identify elements using multiple attributes, for example :class
and :index :

ie.div(:class => 'contentItem', :index => 3)  # access the 3rd div with a
class of 'contentItem'

...I believe that you can also as a variation go for the Nth div within a
div like so:

ie.div(:class, 'content').div(:index, 4)  # access the div with
class='content', and then access the 4th div within it.

Take this last one with a grain of salt - I don't have a page to test it on
right now, but I believe that it works as I describe here.

Hope that helps,
Jeff


--
http://testingjeff.wordpress.com
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to