更新时间:2022-05-28 23:50:20
我会使用下一个 xpath //button[text()='abc']
.您提到了 text()
函数,但我不确定语法是否正确.您还尝试使用 contains()
- 它搜索部分文本,WebDriver 获取找到的第一个元素.我你的情况是 button
I would use next xpath //button[text()='abc']
. You have mentioned text()
function but I'm not sure syntax was correct. Also you tried to use contains()
-- it searches partial text and WebDriver gets first element found. I your case it is <button>abcd</button>
button