I would use something like
# pseudo code
String text = null;
text1 = driver.findElement(By.xpath(xpath1)).getText();
text2 = driver.findElement(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.