<br><br><div><span class="gmail_quote">On 5/2/07, <b class="gmail_sendername">Jason & Aneta</b> <<a href="mailto:freezingkiwis@gmail.com">freezingkiwis@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey all,<br><br>Using the 1.5.1.1158 gem and enjoying the class support.<br><br>Within my web page, I have the following, with 3 <div> nested inside<br>the main "content" <div>.<br><br><div class="content">
<br> <div class="contentItem"><br> </div><br> <div class="contentItem"><br> </div><br> <div class="contentItem"><br> </div><br></div><br>
<br>How do I retrieve / act within the nth instance, i.e. the 1st, 2nd or<br>3rd of these "contentItem" divs?</blockquote><div><br>Hi Jason, <br></div><br>divs (and many other elements) can be accessed by :index. For example:
<br><div><pre>ie.div(:index,2) # access the second div on the page<br><br></pre></div>You can also identify elements using multiple attributes, for example :class and :index :<br><br>ie.div(:class => 'contentItem', :index => 3) # access the 3rd div with a class of 'contentItem'
<br><br>...I believe that you can also as a variation go for the Nth div within a div like so:<br><br>ie.div(:class, 'content').div(:index, 4) # access the div with class='content', and then access the 4th div within it.
<br><br>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.<br><br>Hope that helps,<br>Jeff<br></div><br clear="all"><br>-- <br><a href="http://testingjeff.wordpress.com">
http://testingjeff.wordpress.com</a>