TransWikia.com

Problem implicit wait with wait.until

Software Quality Assurance & Testing Asked by Markus Pallasch on October 25, 2021

In my code, I want to wait a certain time until the command fails with implicit wait for the driver.

I have parts which were loaded after entering the page and a loading-icon is visible. In these cases I need to wait until this icon is not visible. I tried this with wait.until(ExpectedConditions.invisibility...) but the automate is waiting "for ages" and the Icon is gone long before.

I found a workaround for this, but I guess this is not a good way. Is there any better solution for that?

WebDriverWait wait = new WebDriverWait(driver,10);

driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(LoadmaskActive)));
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(LoadmaskActive)));
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

Normal implicitlyWait is for 60 Seconds. It would be nice to get rid of these driver.manage() before and after the wait.until()

One Answer

The problem with implicit wait is that it will wait the full time unless the element being searched for is present. Since you are waiting for an element to go away, the implicit wait is going to last the full time span.

I'd suggest removing the implicit wait entirely and using your two wait.until calls followed by a third wait.until that checks that an element on your page that you know will be enabled once the loading icon is gone is visible, enabled, and interactable.

Answered by Kate Paulk on October 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP