clickLink >> Xpath

View: New views
2 Messages — Rating Filter:   Alert me  

clickLink >> Xpath

by brian.hurst :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

clickLink >> Xpath

Hello all,

I'm new to webtest, and a horrible programmer.  This is what I need Xpath to do:

1. find a table cell containing a plain text string
2. follow a link in the cell two spaces to the left

simplified example of my table:

<table>
<tbody>
<tr>
<td> <a href="link">link</a> </td>
<td> &nbsp; </td>
<td> string </td>
</tr>
</tbody>
</table>

my clickLink tag:

<clickLink
description="find link relative to string"
xpath="//td[contains(text(),'string')-2]/a[1]"
/>



Thank you!
-Brian


Re: clickLink >> Xpath

by Steve Chikwaya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Brian,

Your xpath to finding the text string might look like this:
/html/body/table/tbody/tr/td[1]/a

xpath to find text:
/html/body/table/tbody/tr/td[3]

I find things a lot easier when I assign id's/name's to the element I am working with so as to navigate to it faster.

-Steve C
On Thu, Jun 26, 2008 at 3:53 PM, Hurst, Brian <Brian.Hurst@...> wrote:

Hello all,

I'm new to webtest, and a horrible programmer.  This is what I need Xpath to do:

1. find a table cell containing a plain text string
2. follow a link in the cell two spaces to the left

simplified example of my table:

<table>
<tbody>
<tr>
<td> <a href="link">link</a> </td>
<td> &nbsp; </td>
<td> string </td>
</tr>
</tbody>
</table>

my clickLink tag:

<clickLink
description="find link relative to string"
xpath="//td[contains(text(),'string')-2]/a[1]"
/>



Thank you!
-Brian




--
I'm not the person your mother warned you about... her imagination isn't that good!
LightInTheBox - Buy quality products at wholesale price