涉及开始的 Xpath 不起作用

Oly*_*hun 5 selenium xpath

我遇到了 xpath 表达式的问题。请有人帮助我吗?

所以我的 xpath 是 -".//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>
Run Code Online (Sandbox Code Playgroud)

And*_*son 4

你的XPath不起作用,因为实际上文本以空格/换行符开头,所以你需要删除它们。尝试下面的表达式

.//td[starts-with(normalize-space(.), 'IMT - Office Admin')]
Run Code Online (Sandbox Code Playgroud)