5

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>
Bill Bell
  • 21,021
  • 5
  • 43
  • 58
Olya Bihun
  • 53
  • 4
  • I'm writing to you as a reviewer because this is your first question. The main thing I would say about your question is that it doesn't indicate what help you would like. Is it that you want the contents of the **input**? – Bill Bell Feb 28 '17 at 20:46
  • And if someone gives you an answer that works you should please mark it accepted. – Bill Bell Feb 28 '17 at 20:48

1 Answers1

4

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')]
Andersson
  • 51,635
  • 17
  • 77
  • 129
  • for any copy pasters - [text vs . DOES make a difference](https://stackoverflow.com/questions/38240763/xpath-difference-between-dot-and-text) – Mattwmaster58 Jun 08 '22 at 02:48