Tricky.

I would get all the links that match what you want, and then reject any of
them that are inside the table.

The following entirely untested code may work, or at least give you some
ideas - note that it'll only work in IE due to its reliance on
unique_number; if you want to use firewatir, I can't help you; if you want
to use firefox with vapir-firefox I can come up with something that'll
work.

# get the links that match what I want:
links = browser.links.select{|link| link.href
=~ /imperativeMain.*do.*?navTrailRequired=/ }

# get the table
table = browser.table(:id, 'breadcrumbTable')

# get the links in the table, that I don't want
table_links = table.links.select{|link| link.href
=~ /imperativeMain.*do.*?navTrailRequired=/ }

# reject the table links, matching on unique_number
good_link = links.detect do |link| # find the first link ...
  !table_links.any? do |table_link| # where there aren't any links inside
the table ...
    table_link.unique_number == link.unique_number # with the same unique
number
  end
end

2010/8/25 Shlomit Gazit <shlomitpatr...@gmail.com>

> Guys,
>
> Sorry for the misunderstanding.
>
> First of all I dont have ids. I said in the beginning id but it is actually
> url I am clicking on.
> The links are dynamic so I cannot give the exact one.
> In the page when I am deleting an item, it records the item in recently
> visited table. If after deleting the item I will click on the link in
> Recently visited, I will get to a dead end. It is obviously a bug but it is
> not being fixed for time being, and I will have easier life with watir tests
> if I can get a work around.
>
> I will give you exact examples:
>
> I want to click on this html tag:
>
> <a href="/c2p/imperativeMain.do?navTrailRequired=false&amp;id=1"
> class="linkList" onmouseover="TagToTip('ID_SPAN_CONTEXT_NOTE__1', WIDTH,
> -240, SHADOW, true, BORDERCOLOR, '#e9e1c5', FONTCOLOR, '#000099', BGCOLOR,
> '#ffffc0', STICKY, true, FONTFACE, 'verdana, arial, helvetica', FONTSIZE,
> '11px', CLICKCLOSE, true);" onmouseout="UnTip();">Source: <font
> class="supporting">[Pending] </font><b>SS very long name imperative </b></a>
>
> The link that will lead me to a dead end its html is:
>
> <a onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
> Source', 'be&lt;script&gt;alert(" c...');"="" title="be&lt;script&gt;alert("
> copy")&lt;="" script&gt;?"=""
> href="/c2p/imperativeMain.do?navTrailRequired=false&amp;id=262"><span
> class="breadcrumb_gray">(Source) </span>be&lt;script&gt;alert("C...</a>
>
> For clicking on each of them I will do with watir:
>
> ie.link(:url,/imperativeMain.*do.*?navTrailRequired=/).click
>
> What I found is that the link that leads me to dead end is surrounded by a
> table:
>
> <table id="breadcrumbTable">
>      ...link to dead end...
>
> </table>
>
> I thought it can give me an option to tell watir not to choose this link.
>
> Is it possible?
>
> Again, I cannot access with ids because the items' ids are unexpected.
>
> I hope it is clearer.
>
>
>
>
>
> On Wed, Aug 25, 2010 at 10:24 AM, Chuck van der Linden 
> <sqa...@gmail.com>wrote:
>
>> >>The problem is that the link above has the same url, but I dont want to
>> click on the link in that table since it will take me to a dead end.
>> <<
>>
>> HUH?  If THE URL IS THE SAME, then how can one link lead you somewhere
>> the other link does not?   If both links point to the same URL, they
>> should both take you to the same page, otherwise if they take you
>> different places, they must have different url's .
>>
>> The problem appears to be that you are trying to select via a regular
>> expression, and more than one thing is matching that expression.  Can
>> you change the regex so it will select one unique link instead of
>> matching multiple links on the page??
>>
>> Or another way to consider it, if you were working the page manually,
>> how would you know which link is the one you want to click, what
>> identifies it to you visually?
>>
>> Instead of supplying us with detailed HTML of the table and links you
>> don't want to select, how about you provide some HTML of the one you
>> DO want to select?   Perhaps it is inside some other unique container
>> like a div which could be used to identify it better?
>>
>> On Aug 25, 7:37 am, Shlomit Gazit <shlomitpatr...@gmail.com> wrote:
>> > I have this table:
>> >
>> > <table id="breadcrumbTable">
>> > and inside the table I have:
>> >
>> > <a onclick="pageTracker._trackEvent('Recently visited', 'Recently
>> visited -
>> > Issue', '[1482] - 1AIM-issue_name_1');" title="[1482] -
>> 1AIM-issue_name_1"
>> > href="/c2p/url"><span class="breadcrumb_gray">(Issue) </span>[1482] -
>> > 1AIM-issue_name_1</a>
>> >
>> > I am getting to the link I wish by doing:
>> >
>> > ie.link(:url,/url/).click
>> >
>> > The problem is that the link above has the same url, but I dont want to
>> > click on the link in that table since it will take me to a dead end.
>> >
>> > Index is not working for me since the table is not static and is growing
>> > with deletion of items.
>> >
>> > This is the entire table if it helps better:
>> >
>> > <table id="breadcrumbTable">
>> >         <tbody><tr>
>> >             <td class="breadcrumbs" align="left"><h2>Recently
>> > Visited</h2></td>
>> >         </tr>
>> >
>> >                 <tr>
>> >             <td class="breadcrumb pt_0 pr_8 pb_10 pl_0"><a
>> > onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
>> > Issue', '[1481] - 1AIM-issue_name_1');" title="[1481] -
>> 1AIM-issue_name_1"
>> > href="/c2p/topLevelIssueMainView.do?id=7973"><span
>> > class="breadcrumb_gray">(Issue) </span>[1481] -
>> > 1AIM-issue_name_1</a><br></td>
>> >         </tr>
>> >                 <tr>
>> >             <td class="breadcrumb pt_0 pr_8 pb_10 pl_0"><a
>> > onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
>> > Issue', '[1482] - 1AIM-issue_name_1');" title="[1482] -
>> 1AIM-issue_name_1"
>> > href="/c2p/topLevelIssueMainView.do?id=7975"><span
>> > class="breadcrumb_gray">(Issue) </span>[1482] -
>> > 1AIM-issue_name_1</a><br></td>
>> >         </tr>
>> >                 <tr>
>> >             <td class="breadcrumb pt_0 pr_8 pb_10 pl_0"><a
>> > onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
>> > List', 'All Issues');" title="All Issues"
>> > href="/c2p/setDefaultAllIssueList.do"><span
>> class="breadcrumb_gray">(List)
>> > </span>All Issues</a><br></td>
>> >         </tr>
>> >                 <tr>
>> >             <td class="breadcrumb pt_0 pr_8 pb_10 pl_0"><a
>> > onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
>> > Source', '1Watir-all_1');" title="1Watir-all_1"
>> > href="/c2p/imperativeMain.do?id=10938"><span
>> > class="breadcrumb_gray">(Source) </span>1Watir-all_1</a><br></td>
>> >         </tr>
>> >                 <tr>
>> >             <td class="breadcrumb pt_0 pr_8 pb_10 pl_0"><a
>> > onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
>> > List', 'Sources');" title="Sources"
>> href="/c2p/imperativeMainList.do"><span
>> > class="breadcrumb_gray">(List) </span>Sources</a><br></td>
>> >         </tr>
>> >                 <tr>
>> >             <td class="breadcrumb pt_0 pr_8 pb_10 pl_0"><a
>> > onclick="pageTracker._trackEvent('Recently visited', 'Recently visited -
>> > List', 'Projects');" title="Projects" href="/c2p/projectList.do"><span
>> > class="breadcrumb_gray">(List) </span>Projects</a><br></td>
>> >         </tr>
>> >
>> >     </tbody></table>
>> >
>> > 2010/8/25 Željko Filipin <zeljko.fili...@wa-research.ch>
>> >
>> >
>> >
>> > > On Tue, Aug 24, 2010 at 11:44 PM, Shlomit Gazit <
>> shlomitpatr...@gmail.com>
>> > > wrote:
>> > > > I would like to be able to click on the link that is located outside
>> of
>> > > the table above.
>> >
>> > > Please post sample HTML.
>> >
>> > > Željko
>> > > --
>> > > watir.com - community manager
>> > > watirpodcast.com - host
>> > > testingpodcast.com - audio podcasts on software testing. all of them
>> > > vidipodkast.com - pričamo o hardveru, softveru i časopisu Vidi
>> >
>> > > --
>> > > Before posting, please readhttp://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<watir-general%2bunsubscr...@googlegroups.com>
>> <watir-general%2bunsubscr...@goog legroups.com>
>>
>> --
>> 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<watir-general%2bunsubscr...@googlegroups.com>
>>
>
>  --
> 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<watir-general%2bunsubscr...@googlegroups.com>
>

-- 
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

Reply via email to