2
votes

There have been questions on the difference between implicit and explicit wait in Selenium WebDriver.

What is difference between Implicit wait Vs. Explicit wait in selenium webdriver?

When to use explicit wait vs implicit wait in Selenium Webdriver?

On SeleniumHq also:

Implicit Waits

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.

But not clear what kind of wait is this, I mean would it wait till isDispalyed, isVisible or isClickable

2

2 Answers

1
votes

I believe the implicit wait does not care about any of those properties (isDisplayed, isVisible or isClickable). It just waits the time you set up and checks regularly whether the element you try to select is available in your DOM. If it is not found it will lauch a timeout error.

0
votes

I believe narko is right and here's some code that I think proves it.

By hiddenLocator = By.id("csi");
FirefoxDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.google.com");
WebElement hiddenEle = driver.findElement(hiddenLocator);
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(hiddenLocator));
System.out.println("done");

I went to google.com and found an element that was hidden

<textarea name="csi" id="csi" style="display:none"></textarea>

I set the implicit wait to 30s, set up a WebDriverWait for 30s, and then waited for the element to be present. From the presenceOfElementLocated() source

An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible.

If implicit wait was waiting for anything other than just the presence of the element in the DOM, it would have waited for 30s... but it finished as soon as the page was loaded in the browser.

I did some research to better understand what these different functions are doing and how they are truly different. Here's what I found...

WebElement has three methods related to this question: isDisplayed(), isEnabled(), and isSelected(). From the docs...

isDisplayed() Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.

isEnabled() Is the element currently enabled or not? This will generally return true for everything but disabled input elements.

isSelected() Determine whether or not this element is selected or not.

ExpectedConditions also comes into play here with several methods. I'll just look briefly at elementToBeClickable(). From the docs...

elementToBeClickable An expectation for checking an element is visible and enabled such that you can click it.

If you look at the source, the description is accurate. You can look at the source for the other methods, etc. if you want more info but I think this is enough to answer your question.