Reputation: 484
I'm using the fluentWait()
on my selenium
code. But I noticed that although the element need waited has been loaded on the browser, it is still waiting for a while. It wastes a lot of time, but I don't know the reason. Does anyone knows why is it?
Upvotes: 0
Views: 181
Reputation: 5647
Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.
// Waiting 30 seconds for an element to be present on the page, checking
// for its presence once every 5 seconds.
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
Will be slower as:
// Waiting 30 seconds for an element to be present on the page, checking
// for its presence once every 1 second.
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(1, SECONDS)
.ignoring(NoSuchElementException.class);
So, it depends on you what you will use.
Upvotes: 2