0

So basicly I have this HTML code:

    <td class="google">
        <a href="#">I love my job
    </td>

and I want to search in the web if there is really a link "I love my job".

So I used this xpath to find that:

"//td[@class=google]//a[text()='I love my job']"

But it is not workink for me.

What should be the xpath code ?

Thanks in advance !!

4
  • What tool are you using to execute the XPath? Please detail how it isn't working. Commented Dec 10, 2013 at 9:52
  • I am sorry. I run this code xpath code and there was no element like this found Commented Dec 10, 2013 at 9:52
  • I am using WebDriver.findElement() Commented Dec 10, 2013 at 9:54
  • your a tag is not closed... Commented Dec 10, 2013 at 10:07

1 Answer 1

1

That's because the text value of your link is not 'I love my job', but 'I love my job\n '.

Use normalize-space().

"//td[@class='google']//a[normalize-space(text())='I love my job']"
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.