i am trying to search on item then result if found appear in specific element and if not found another element will appear so i tried to use OR with expected conditions like below:
wait.until(ExpectedConditions.or(ExpectedConditions.visibilityOf(SearchResult),
(ExpectedConditions.visibilityOf(SerachGetData))));
i want to know if there is a way to know which Element appear SearchResult or SearchgetData
You can fetch the list of those elements and then check size of which list is greater than zero, because the if the element list size is greater than zero then that element is present on the page.
You can do it like:
List<WebElement> elementList1 = driver.findElements(By.xpath("Add the xpath of first element here"));
List<WebElement> elementList2 = driver.findElements(By.xpath("Add the xpath of second element here"));
if(elementList1.size()>0){
//Element 1 is present on the UI
} else if(elementList2.size()>0){
//Element 2 is present on the UI
} else{
//Both the elements are not present
}