Thanks Chuck.  In this case, each link is to a different URL, but
whether I want to click there in my test is determined by whether some
text is located immediately above it.  Normally the devs do a great
job of putting names and ids on every little piece, but as this is for
mobile browsers (like the blackberry), they've kept it as simple as
possible so that all browsers could read it and it would download
quickly.  It probably wouldn't hurt for them to add some things like
names and ids, but then they'd have to put in tables, divs, etc.,
which they are hesitant to do as they are trying to keep things as
absolutely simple as possible.

The advice above is helping me, although I'm having some issues using
the "after?" how, as I mentioned in a new thread I just opened up.  It
seems to work for me with certain kinds of elements, but not others.

I'm going to keep hacking away at it for a bit, but in the end I may
just give up on it.  It may just not be worth automating the testing
on this.

Thanks again,
James

On Jun 3, 3:23 pm, Chuck van der Linden <[email protected]> wrote:
> unless my HTML is really rusty, 'b' tags are for boldface.    normally
> I'd try looking the next container up.  but in this case it would
> appear that whatever that container is (we can't tell from the
> fragment you gave us) there's more text in there than that.. including
> text in other <b> tags
>
> You might end up having to learn a bit about regular expressions to
> tackle this one.
>
> I'm guessing you can't predict the URL for that link, or you'd be
> identifying it that way right?  and that unlike your examples the URL
> for each link is in fact different (otherwise, clicking one is as good
> as clicking another)
>
> man too bad they didn't stick those things into a table or something,
> that would make your life a lot easier.
>
> is 'testability' a requirement for the site you are testing against?
> if so maybe you could persuade the devs to make a few changes that
> would make it easier to automate?  like oh  a 'Name' attribute for the
> link that is the same as the nearby text that identifies it visually
>
> On Jun 3, 9:38 am, James <[email protected]> wrote:
>
> > Thanks Darin - that's really helpful!  Now I just need to know how to
> > latch onto the text surrounded by the <b></b>.  Any ideas?  If that
> > works, then I can definitely use the "after?" method to grab the link
> > after it.
>
> > (I'm still looking at xpath, but I've never used xpath before and am
> > finding it quite confusing!)
>
> > Thanks,
> > James
>
> > On Jun 3, 12:27 pm, "Darin Duphorn" <[email protected]>
> > wrote:
>
> > > Below is code that gets the div that appears after a label, this might 
> > > also help.
>
> > > label_id = $ie.div(:after?, $ie.label(:text,'Home')).span(:index,1)  
>
> > > -----Original Message-----
> > > From: [email protected] 
> > > [mailto:[email protected]] On Behalf Of James
> > > Sent: Wednesday, June 03, 2009 11:24 AM
> > > To: Watir General
> > > Subject: [wtr-general] Re: Finding a specific instance of a repeated link 
> > > via text surrounding it.
>
> > > It's more like I just want to grab an element based on where it is in
> > > reference to another element, or in reference to text on the page.
>
> > > I noticed Charley's mention of xpath and am looking into it right now
> > > - I think it might be what I'm looking for, unless someone has another
> > > suggestion.
>
> > > James
>
> > > On Jun 3, 12:21 pm, "Darin Duphorn" <[email protected]>
> > > wrote:
> > > > Ok, you want to us the information in the <B> tag to determine what 
> > > > link to click.
>
> > > > But the <B> isn't a supported tag, so you don't know how to use it.
>
> > > > Is this a correct?
>
> > > > -----Original Message-----
> > > > From: [email protected] 
> > > > [mailto:[email protected]] On Behalf Of James
> > > > Sent: Wednesday, June 03, 2009 11:17 AM
> > > > To: Watir General
> > > > Subject: [wtr-general] Re: Finding a specific instance of a repeated 
> > > > link via text surrounding it.
>
> > > > But the text I'm referring to isn't part of the link itself.  The link
> > > > text is the same.  I'm looking at the text that occurs -before- (or
> > > > possibly after) the link.
>
> > > > Thanks for your suggestions, but unfortunately, in this example, it
> > > > won't work.
>
> > > > James
>
> > > > On Jun 3, 12:13 pm, Charley Baker <[email protected]> wrote:
> > > > > Could also use multiple attributes:
>
> > > > > browser.link(:index => 1, :text => /Click This Link/).click
>
> > > > > or xpath.
>
> > > > > Charley Baker
> > > > > blog:http://blog.charleybaker.org/
> > > > > Lead Developer, Watir,http://wtr.rubyforge.org
> > > > > QA Architect, Gap Inc Direct
>
> > > > > On Wed, Jun 3, 2009 at 10:10 AM, Darin Duphorn
> > > > > <[email protected]>wrote:
>
> > > > > > Browser.link(:text,/Click This Link/).click
>
> > > > > > -----Original Message-----
> > > > > > From: [email protected]
> > > > > > [mailto:[email protected]] On Behalf Of James
> > > > > > Sent: Wednesday, June 03, 2009 11:08 AM
> > > > > > To: Watir General
> > > > > > Subject: [wtr-general] Finding a specific instance of a repeated 
> > > > > > link
> > > > > > via text surrounding it.
>
> > > > > > I'm trying to figure out how to click on a link, and the only way I
> > > > > > know which link to click on is from text that comes before it.
> > > > > > Otherwise, it looks the same as other links on the same page.
>
> > > > > > So for instance, the html might look like:
>
> > > > > > <b>Click This Link</b>
> > > > > > <br>
> > > > > > <a href="http://clickhere.com";>The Link</a>
> > > > > > <br>
> > > > > > <b>But Not this link</b>
> > > > > > <br>
> > > > > > <a href="http://clickhere.com";>The Link</a>
>
> > > > > > I want to be able to read the page and latch onto the link with the
> > > > > > "Click This Link" but not other ones.  In fact, if there are 
> > > > > > multiple
> > > > > > "Click This Link" links, I want to be able to find all of them, and
> > > > > > ignore the rest.
>
> > > > > > I'm at a loss how to do this with Watir.  I'm used to being able to
> > > > > > find things by div and id tags, etc., but this is a dumbed down page
> > > > > > meant for mobile devices and it lacks almost all of the things I'm
> > > > > > used to latching onto.
>
> > > > > > Any suggestions?- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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