Olya Bihun
Olya Bihun

Reputation: 53

Xpath involving a starts-with not working

I'm stuck on a problem with an xpath expression. Could some body help me, please?

So my xpath is - ".//td[starts-with(text(), 'IMT - Office Admin:')]"

DOM :

<td>
 <input type="checkbox" name="partyEditF:j_id698:6:j_id700">
                IMT - Office Admin: Ability to edit everything within your office including the office's information and listings
</td>

Upvotes: 5

Views: 940

Answers (1)

Andersson
Andersson

Reputation: 52665

Your XPath doesn't work because actually text starts with spaces/new line characters, so you need to get rid of them. Try below expression

.//td[starts-with(normalize-space(.), 'IMT - Office Admin')]

Upvotes: 4

Related Questions