Doesn’t seem to change anything. I believe it’s still internally calling driver.findElement, which still blocks for 25 seconds. Hypothesis: FluentWait and WebDriverWait are the same thing with different APIs, although FluentWait has more options.
FluentWait wait = new FluentWait(driver)
.withTimeout(Duration.ofSeconds(5))
.pollingEvery(Duration.ofSeconds(1))
.ignoring(Exception.class);
// still blocks for 25 seconds
wait.until(ExpectedConditions.elementToBeClickable(By.id("foobar")))
Right. FluentWait polls for the element using .pollingEvery(seconds), and during that poll it can ignore an exception with .ignoring(exception). If you are getting a elementMissing exception, you can ignore it for the duration that you’d like to poll. Looks like you’ve set .withTimeout to 5 seconds, maybe give it more time? The nice thing about the FluentWait is that if the element is found before the .withTimeout time expires it will return the element. So setting that to a very large value (say 30 seconds) should simply return the element before that time is reached. This is a very good way to stabilize tests.
after scroll do not look for x sec better user simple findElement and try tap directly. and limit all with time you want:
// add set implicit wait to 1 sec
long startTime = System.currentTimeMillis();
do {
if (tap(driver.findElement(MobileBy.id("element_id")))) // this is fast element search and tap
break;
do_scroll();
} while (System.currentTimeMillis() < startTime + 20 * 1000); // 20 sec MAX
// add restore implicit wait to 25 sec
// tap function is any way of tap you know (they are many. i like w3c way today) with return result true / false
elementToBeClickable -> visibilityOfElementLocated(locator).apply(driver);
// where
visibilityOfElementLocated -> return elementIfVisible(driver.findElement(locator));
// where
`driver.findElement` uses your Implicit time of 25 sec
FluentWait blocks for the full 25 seconds from driver.manage().timeouts().implicitlyWait(25) regardless of what I set FleuntWait’s options to. I don’t want to change the implicitlyWait setting because there seems to be no way to restore it.
that’s what i’m using to swipe; seems to work fine.
still blocks for 25 seconds.
for various reasons, the element ID i’m looking for is dynamic. I can’t hard-code it in an annotation. Is there another way to do this?