I’m writing a Python script that uses Selenium to select all clickable buttons by XPath.
I have these XPath expressions:
//button
//input[@type='submit']
//input[@type='button']
Is there a way to join these in a single XPath expression, to select only these types of elements?
>Solution :
You can check for the names and the attributes
//*[name()='button' or (name()='input' and (@type='submit' or @type='button'))]
or use the merge operator on three different queries
//button | //input[@type='submit'] | // input[@type='button']
Output should be the same, but the resulting order may be different.