【问题标题】:Find xpath of an element using text使用文本查找元素的 xpath
【发布时间】:2021-07-25 04:42:58
【问题描述】:
<div class="css-ki-menu">
<div class="css-11ur">
<div class="css-d0i-option" id="react-select-3-option-0" tabindex="-1">L3</div>
<div class="css-f5s-option" id="react-select-3-option-1" tabindex="-1">L4</div>
</div>
</div>

我有文本 'L3' 有没有办法使用文本找到相对 xpath?

新手请帮帮我

谢谢

【问题讨论】:

标签: javascript html python-3.x selenium selenium-webdriver


【解决方案1】:

要定位带有L3 文本的元素,如示例中提供的,您可以简单地使用//div[contains(text(),'L3')]//div[text()='L3']
如果您需要此 xpath 与其他元素相关 - 请提供更多详细信息。

【讨论】:

    猜你喜欢
    • 2021-01-26
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 2020-06-07
    • 1970-01-01
    • 1970-01-01
    • 2019-08-18
    • 2015-11-26
    相关资源
    最近更新 更多