0

i have to find the following href using selenium in java

<tr>
   <td>
     <a target="mainFrame" href="reb.php?tiEx=ES"></a>
   </td>
</tr>

thanks

5
  • Okay... What are you looking for from us? Do you have any existing code that you've tried? Commented Aug 27, 2014 at 15:10
  • Did you omit some of the quotes? Shouldn't it be target="mainFrame" href="reb.php?tiEx=ES"? Otherwise, the HTML (?) is garbage if you excuse my French. Commented Aug 27, 2014 at 15:17
  • yes, by mistake i omited some quotes Commented Aug 27, 2014 at 15:37
  • At least specify what language you're using!!!!! Commented Aug 27, 2014 at 15:43
  • Your title says "find href" whereas in your XML sample, there is no href attribute, but target. That does not make sense to me. Commented Aug 27, 2014 at 15:55

1 Answer 1

2

There are multiple ways to find the link depending on the elements it is inside and the uniqueness of the element attribute values on the page, but, from what you've provided, you can rely on the target attribute:

//a[@target="mainFrame"]

You can also narrow it down to the scope of it's parents:

//tr/td/a[@target="mainFrame"]

Also, you can additionally check the href attribute if it is persistent and reliable:

//tr/td/a[@target="mainFrame" and @href="reb.php?tiEx=ES"]
Sign up to request clarification or add additional context in comments.

Comments

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.