我正在尝试从下面的 html 示例中获取“RGF Administrator”文本。困难在于标题可以采用两个值:“应用程序设置”或“Параметры приложения”。同时,html 可能包含其他 title = '应用程序选项' 的元素。
我可以使用 xPath 来实现哪些功能?
<div>
<button
title="Application options">
<span>
<span>
<bdi>
RGF Administrator
</bdi>
</span>
</span>
</button>
</div>
我使用 selenium,但无法确定“RGF Administrator”的 xPath。
xpath = "//*[@title='Параметры приложения' 或 @title='应用程序选项']"
不会工作,因为同时 html 可能包含标题=“应用程序选项”的其他元素。
最佳答案
在实际的 xml 上尝试这个 xpath 表达式,看看它是否有效:
//div/button[@title = ('Параметры приложения', 'Application options')]//bdi/text()
关于html - 如何使用 XPath 在 HTML 中搜索标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58396264/