You might have to do

div(:class => "NavigationLink", :index => 4).click

The :index is 1-based, so the fourth link would be index = 4. This is one of
the really helpful features of Watir, namely multiple attributes so that you
can define exactly which element to click on or manipulate more
specifically.

Nathan

On Thu, Oct 9, 2008 at 3:44 PM, NS <[EMAIL PROTECTED]> wrote:

>
> Nathan,
>
> Thanks for your reply.
>
> There is no actual <A> tag that I see in the IE toolbar.
>
> The HTML structure that I have posted with original message is the one
> I see in IE toolbar and the places where I have put "..." between
> <DIV> tags..there are more divs there.I don't know how to attach a
> screenshot here otherwise I can attach the Excite Mail page and you
> can see how things are rendered.
>
> Also I was wondering how div(:class, "NavigationLink") would find the
> "Logout" link only because there are other divs defined with the same
> class.
>
> Thanks,
> Nisha
>
> On Oct 9, 2:15 pm, "Nathan Lane" <[EMAIL PROTECTED]> wrote:
> > On thing about Watir is that it generally does what the browser does, so
> if
> > you really click on a DIV to perform an action on a web site, then using
> > Watir click on the DIV. This may be the case here with your situation,
> > though I am not certain how Excite Mail is actually structured (your HTML
> > example is obviously trimmed down quite a bit), and I don't see and links
> > (<A HREF="...">...</A> tags). Anyway for example, if I have a DIV that is
> > like this:
> >
> > <div class="navigationLink" onclick="javascript:
> logMeOut();">Logout</div>
> >
> > Then I could just go
> >
> > div(:class, "navigationLink").click
> >
> > likewise let's say that I have this structure, and no other "links" are
> > located under it. i.e. this is the exact structure:
> >
> > <div class="navigationLink" onclick="javascript: logMeOut();">
> >   <div>
> >     <div>
> >       <div>
> >         Logout
> >       </div>
> >     </div>
> >   </div>
> > </div>
> >
> > Then I can still do
> >
> > div(:class, "navigationLink").click
> >
> > and the browser will feel the click down at the bottom..actually it feels
> it
> > at the top, but the link the user would see is at the bottom.
> >
> > Nathan
> >
> >
> >
> > On Thu, Oct 9, 2008 at 12:38 PM, NS <[EMAIL PROTECTED]> wrote:
> >
> > > Hello,
> >
> > > I am new to Ruby and Watir and as my first assignment, I am trying to
> > > fix the ruby script which automated the opening and browsing messages
> > > in the Excite Mail. After Excite changed interface, the script has
> > > been failing.
> >
> > > I used IE toolbar to see the underlying elements in the page and it
> > > seems that it is lots of nested divs before you find an actual #text
> > > which provides the visible text for the link.
> >
> > > I am not sure how to access the divs deep down to find the text value
> > > I want and than click it.
> >
> > > The structure of HTML for "Logout" link looks like this.
> >
> > > <DIV class=ApplicationHeader id=ApplicationHeader>
> > >  <DIV class=NavigationBar>
> > >    <DIV class=NavigationBar_Padding>...</DIV>
> > >    <DIV class=NavigationBar_logo>...</DIV>
> > >    <DIV class=NavigationBar_buttons>...</DIV>
> > >    <DIV class=NavigationBar_extra>
> > >      <DIV class=NavigationBar_Search>
> > >      <DIV class=NavigationBar_Links>
> > >        <DIV class=NavigationLink>...</DIV>
> > >        <DIV class=NavigationLink>...</DIV>
> > >        <DIV class=NavigationLink>...</DIV>
> > >        <DIV class=NavigationLink>
> > >          <DIV class=NavigationLink_Icon>...</DIV>
> > >          <DIV class=NavigationLink_text>
> > >             #text
> >
> > > I tried following but it didn't work.
> >
> > >         if ($ie.div(:id, "ApplicationHeader").div(:index,
> > > 1).div(:index,4).div(:index,2).div(:index,4).div(:text,/
> > > Logout/).exists?)
> > >            thr = Thread.new{$ie.div(:id,
> > > "ApplicationHeader").div(:index,1).div(:index,4).div(:index,
> > > 2).div(:index,4).div(:text,/Logout/).click}
> > >            if (thr.join(MaxPageLoadWait).nil?)
> > >              thr.exit
> > >            end
> > >            debug "Clicked logout link"
> > >          end
> >
> > > I am able to find the div ApplicationHeader using following
> >
> > > $ie.div(:id, "ApplicationHeader")
> >
> > > Any help would be highly appreciated.
> >
> > > Thanks,
> > > Nisha
> >
> > --
> > Nathan Lane
> > Home,http://www.nathandelane.com
> > Blog,http://nathandelane.blogspot.com
> >
>


-- 
Nathan Lane
Home, http://www.nathandelane.com
Blog, http://nathandelane.blogspot.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to