[wtr-general] Re: Problem finding a way to access a link

2010-08-13 Thread Chuck van der Linden
OK so what you have is a link with no text or anything of it's own,
just a 'naked' link, cohabitating in a cell with some text.

At the manual UI level it works because the objects all superimpose
and when someone positions the mouse over the text, they end up
clicking the link

Watir wise, what's worked for me with stuff like this is to identify
it much the same way I described it above..  The unique identifier
here is the text (I'd presume)..  So lets identify the outer
container, namely the cell, by that text, and then click the link
that's inside that cell, which we can identify 'loosely' since it's
the only link there.

browser.cell(:text, Sources).link(:href, /javascript/).click

I'm matching the link on just a portion of the href, which should work
given it's the only link inside that cell.  Since we're confined to
the cell, I don't have to worry about it matching up with a bazillion
other javascript powered links in the app.

  You could also use Index, but I've a habit of trying to avoid using
index since that's an area of contention between firewatir and watir

Now, if there's more than one cell on the page with the text 'Sources'
inside it, this is a bust and you have to find some other path to
uniquely identify the 'container' elements that are holding the link
you want.

On Aug 12, 11:14 am, Melissa meisa...@gmail.com wrote:
 I'm trying to get my Watir test to click the link below, and I'm
 coming up empty. I've tried accessing it by text, href, title, cell,
 table, link index and anything else I could think of. It's such messy
 code - I'm starting to wonder if it's even possible to get at it.

 Any thoughts on what I can use to click the link? Thanks for any tips!

 td nowrap title=Business Objects To Query width=100 height=20
 bgcolor=#efefe7 align=center style=font-size:90%;border-
 right:#94a6ce 1px solid;padding-right:4px;border-top:#94a6ce 1px
 solid;padding-left:4px;border-left:#94a6ce 1px solid;width:
 100px;color:black;border-bottom:#FF9900 1px solid;font-
 family:tahoma;height:20px;background-color:#efefe7;text-
 align:center;text-decoration:none;font face=tahoma color=black
 a
 href=javascript:document.aspnetForm.__ctl00_TemplateBody_DesignShell1_ctl0 
 0_ctl00_SectionTabStrip_State__.value='1';__doPostBack('ctl00$TemplateBody
 $DesignShell1$ctl00$ctl00$SectionTabStrip','1')
 font color=blackSources/font/a/font
 /td

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Problem finding a way to access a link

2010-08-12 Thread orde
If at all possible, try to get a developer to add an id tag (or some
unique element attribute like name or value) to the href so that you
can locate it more easily.

Otherwise, you could try something like this:

$browser.link(:href, /some_unique_part_of_href/).click
or
$browser.link(:href, /some_unique_part_of_href/).fire_event('onclick')

Hope it helps.

orde

On Aug 12, 11:14 am, Melissa meisa...@gmail.com wrote:
 I'm trying to get my Watir test to click the link below, and I'm
 coming up empty. I've tried accessing it by text, href, title, cell,
 table, link index and anything else I could think of. It's such messy
 code - I'm starting to wonder if it's even possible to get at it.

 Any thoughts on what I can use to click the link? Thanks for any tips!

 td nowrap title=Business Objects To Query width=100 height=20
 bgcolor=#efefe7 align=center style=font-size:90%;border-
 right:#94a6ce 1px solid;padding-right:4px;border-top:#94a6ce 1px
 solid;padding-left:4px;border-left:#94a6ce 1px solid;width:
 100px;color:black;border-bottom:#FF9900 1px solid;font-
 family:tahoma;height:20px;background-color:#efefe7;text-
 align:center;text-decoration:none;font face=tahoma color=black
 a
 href=javascript:document.aspnetForm.__ctl00_TemplateBody_DesignShell1_ctl0 
 0_ctl00_SectionTabStrip_State__.value='1';__doPostBack('ctl00$TemplateBody
 $DesignShell1$ctl00$ctl00$SectionTabStrip','1')
 font color=blackSources/font/a/font
 /td

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

You received this message because you are subscribed to 
http://groups.google.com/group/watir-general
To post: watir-general@googlegroups.com
To unsubscribe: watir-general+unsubscr...@googlegroups.com