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);
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()

  • I am not getting why just waiting for invisibility does not work? Because it is triggered before the icon is rendered?
    – Alexey R.
    Jul 15, 2020 at 17:10
  • why are using implicit wait ?
    – PDHide
    Jul 15, 2020 at 19:56
  • I need to wait for an element to be invisible because otherwise there will be some other problems with the page. As you see from the code I am waiting for a Loading-Icon to be visible and after that to be invisible to be sure that all data on the page is available. If I don't wait for that in the following call would be data missing and the test will fail. Jul 17, 2020 at 6:14

1 Answer 1


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.

  • I thought the implizit wait is nothing else than a wait for something to happen for every step. driver.findElement(Testelement).click() This would fail if the Testelement is not found within the defined time in implizitlyWait. Maybe I did not get the point how implizit wait really works. Jul 17, 2020 at 6:21
  • @MarkusPallasch - according to the Selenium documentation (selenium.dev/selenium/docs/api/dotnet/?topic=html/…), it waits until the desired element is found. That isn't going to work well with waiting for an element to go away.
    – Kate Paulk
    Jul 17, 2020 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.