Home > OS >  How to find element using the value attribute with Selenium and XPath
How to find element using the value attribute with Selenium and XPath

Time:08-27

In selenium I used the following XPATH to find all elements which have the word ok:

//button[(((@value='ok')) or ((@value='Ok')) or ((@value='OK')))]

What if I want to find all buttons which start with the word ok? As an example OK1 is a match.

CodePudding user response:

To find all elements which have the word ok you can modify as follows:

//button[@value='ok' or @value='Ok' or @value='OK']

and to find all elements which starts with the word ok you can use:

//button[starts-with(@value, 'ok') or starts-with(@value, 'Ok') or starts-with(@value, 'OK')]
  • Related