I know that, according to some opinions, in the perfect case I should not be using implicit wait. But I have a slow UI; it would be a rather big endeavour to add explicit waits to all the numerous places where rendering can happen. A standard implicit wait of 20 seconds, set at driver initialization time, covers 80% of waiting perfectly.
But then I need to handle the remaining 20%. Sometimes I need to wait for an element to DISappear - and the implicit wait means an extra 20 seconds in this case. And sometimes I need to check for the presence of an element but not wait for it for all of 20 seconds (because the element is often not there in the normal execution flow).
So, I naturally want to disable the implicit wait temporarily:
driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
new WebDriverWait(driver, MY_TIMEOUT)).until(ExpectedConditions.WHATEVER_I_NEED);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
But will this be stable? Or is changing implicit wait (in this case, from 20 to zero and back to 20) somehow dangerous?