简体   繁体   中英

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?

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']
If you need this xpath to be relative to some other element - please provide more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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