I am using the same code as above to find an element.Below is the code which i am using:
Wait wait = new FluentWait((IOSDriver) device.getDriver())
.withTimeout(10, TimeUnit.SECONDS)
.pollingEvery(250, TimeUnit.MILLISECONDS)
.ignoring(NoSuchElementException.class)
.ignoring(TimeoutException.class);
foo = wait.until(new Function<IOSDriver, IOSElement>() {
public IOSElement apply(IOSDriver driver) {
IOSElement x = (IOSElement) driver.findElement(By.id("id"));
if(!(x.isEnabled())){
x = null;
}
return x;
}
});
The presence of the element, i am trying to find is uncertain, sometimes it is present and sometimes it isn't. So if it is present i want to handle it and if it isn't i want to ignore that element without throwing Exception "NoElementFoundException" which is what Fluent wait is expected to do. While execution, the driver waits for the element for 10 seconds and after that throws the "NoElementFoundException" which ruins the whole idea of using FluentWait as i have already given this exception in ignoring condition. I am trying to run this code for an ios app on real ios device. Any help will be appreciated. I have also checked that i have added correct Exception classes
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.TimeoutException;