valid xpath expression from html
Question:
i ha ve this html
<yt-formatted-string id="text" class="style-scope ytd-button-renderer style-primary size-default">
All
</yt-formatted-string><paper-ripple class="style-scope tp-yt-paper-button">
this xpath works with selenium python
//yt-formatted-string[text()='All']
but how can i include the part id="text" of the html to my xpath expression to be valid
to find with selelnium python
thanks a lot
Answers:
You can use
//yt-formatted-string[@id='text' and text()='All']
or the more general approach
//yt-formatted-string[@id='text' and contains(text(),'All')]
i ha ve this html
<yt-formatted-string id="text" class="style-scope ytd-button-renderer style-primary size-default">
All
</yt-formatted-string><paper-ripple class="style-scope tp-yt-paper-button">
this xpath works with selenium python
//yt-formatted-string[text()='All']
but how can i include the part id="text" of the html to my xpath expression to be valid
to find with selelnium python
thanks a lot
You can use
//yt-formatted-string[@id='text' and text()='All']
or the more general approach
//yt-formatted-string[@id='text' and contains(text(),'All')]