I am looking for a way to verify element present for either of two elements.
The scenario is on a particular page:
- Both elements can be present
- One of the two elements can be present
But the test should fail if both elements are not present.
I have the following:
assert WebUI.verifyElementPresent(findTestObject('Object1'), 1, FailureHandling.OPTIONAL) || WebUI.verifyElementPresent(findTestObject('Object2'), 1, FailureHandling.OPTIONAL)
This code works when it doesn’t find one of the two test objects. For example, if it does not find the first one, it checks the second statement and moves on. Similarly if it finds the first one, it tries to find the second but fails and still continue, which is fine.
But when it neither finds the first one, nor the second one, it still continues due to OPTIONAL failure handling. And if I change the failure handling to STOP_ON_FAILURE, the test fails if it does not find one of the two elements.
Can someone let me know how I can manage this?