Skip to main content
2 of 2
added 2 characters in body
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113

I would use something like

# pseudo code
String text = null;
text1 = driver.findElements(By.xpath(xpath1)).getText();
text2 = driver.findElements(By.xpath(xpath2)).getText();
if text1 <> '' or text2 <> '' then  # NOTE: I don't know java syntax!
  code...

You might have to use findElements (note plural) and check for the array size being zero (that is if findElement raises an error). findElements tends to get around that by just returning an empty array.

Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113