Reputation: 24508
Does the first line alone make webdriver wait for 10 seconds? or do I need to have both?
WebDriverWait wait = new WebDriverWait(firefoxDriver,10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpathID)));
I'm confused about what statement makes driver wait?Is this statement enough?
WebDriverWait wait = new WebDriverWait(firefoxDriver,10);
Upvotes: 0
Views: 153
Reputation: 16201
There are three distinct wait mechanisms Selenium
provides so far I know. Explicit
,Implicit
and Fluent
. See this. The one you have mentioned is Explicit
. Explicit wait is meant to wait for element to meet certain condition you tell the WebDriver
. Such as element's visibility(the one you are using),element exists etc. There is a class in org.openqa.selenium.support.ui
named ExpectedConditions
that has good number of members to provide different mechanism for waiting for the element.See here for a complete list.
Going back to your question:
WebDriverWait wait = new WebDriverWait(firefoxDriver,10);
only defines the wait and the length WebDriver
should wait to meet condition provided by you(in second line.)
The actual wait happens wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpathID)));
.
WebDriver
tries to find the element matching the xpathID
and it's visibilty on the page and after 10s
it throws exception. If WebDriver
finds the target element before 10s
it will not wait 10s
and move forward.
Upvotes: 1
Reputation: 5667
WebDriverWait wait = new WebDriverWait(firefoxDriver,10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpathID)));
Wait will ignore instances of NotFoundException that are encountered (thrown) by default in the 'until' condition, and immediately propagate all others.
You can add more to the ignore list by calling ignoring(exceptions to add) method.
Upvotes: 1