0

I am trying to figure out a way to locate an element with XPath based on two text strings. The element in question can have text A or text B, both of which are valid, and I need to assert that this element is visible, based upon this text. So I need an XPath expression like "//*...[contains(text(), 'A')] OR [contains(text(), 'B')]". Is this possible? This must be using XPath 1.0 as it is for Selenium Webdriver.

I have not found any way to do this, so I'm currently checking for the first string in a try-catch, then asserting for the second string afterwards.

0

1 Answer 1

7

Yes, You can use XPath with OR Logical condition as follows :

  • //*[contains(text(),'A') or contains(text(),'B')]
  • //*[text()='exact_Text_1' or text()='exact_text_2']

  • //*[@class='abc' or @class='pqr']

Sign up to request clarification or add additional context in comments.

1 Comment

This was exactly what I was looking for, thank you!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.