Home > Mobile >  valid xpath expression from html
valid xpath expression from html

Time:10-25

i ha ve this html

<yt-formatted-string id="text" >
All
</yt-formatted-string><paper-ripple >

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

CodePudding user response:

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')]
  • Related