简体   繁体   English

使用文本查找元素的 xpath

[英]Find xpath of an element using text

<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>

I have the text 'L3' is there any way to find the relative xpath using the text?我有文字'L3'有没有办法使用文字找到相对的xpath?

Please help me out am new to it请帮助我是新手

Thank you谢谢

To locate element with L3 text as in the example provided you can simply use //div[contains(text(),'L3')] or //div[text()='L3']要在提供的示例中定位具有L3文本的元素,您可以简单地使用//div[contains(text(),'L3')]//div[text()='L3']
If you need this xpath to be relative to some other element - please provide more details.如果您需要此xpath与其他元素相关 - 请提供更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM