"A1" ...">

Xpath: Get button by type and text

I have a webpage with the following template:

<body> ... <a type="submit"....> "A1" </a> <a type="submit"....> "A2" </a> <a type="submit"....> "A3" </a> <a type="submit"....> "A4" </a> <a type="submit"....> "A5" </a> ... </body> 

I find the whole set of β€œbuttons” with the following query:

 //a[@type='submit'] 

The question is what should I add in order to get a special button, say, "A4"

10x

+4
source share
1 answer

Assuming that there are no useful attributes in elements a (e.g. class or id ), you can use the contains XPath function:

 //a[@type='submit' and contains(., "A4")] 
+9
source

Source: https://habr.com/ru/post/1485016/


All Articles