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.

to6y
  • 96
  • 1
  • 9

1 Answers1

6

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']

Pritam Maske
  • 2,670
  • 2
  • 22
  • 29