0

I have a page on the UI where the data looks like this

name1 label1 name2 label2 name3 label3 name4 label4 name5 label5 name6 label6

If i have to look for name3 and also verify that label3 is adjacent to it? how would I do it? the names have no id and name associated with them. checked in firebug.

the fir bug shows something like this:

<table class="content-grid" width="95%" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<tr class="content-grid-stripe-light">
<td>name1 </td>
<td>
</tr>
<tr class="content-grid-stripe-dark">
</table>

Can someone please suggest.

1
  • Could you show the relevant part of the html containing label3 and name3? Commented May 14, 2014 at 12:57

1 Answer 1

1

If you are using selenium WebDriver, you can follow those steps:

  1. use tableRows = driver.findElements(By.xpath("//tr/td")) to put in tablerows all your td elements

  2. fetch your tablerows and make a comapare between tableRows[i] and tableRows[i+1], for example if(tableRows.get(i).getText()).equals((tableRows.get(i+1).getText())) then .........

Use something like that, I hope that this will be useful to you

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks For the suggesting. It helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.