Selenium: working of Fluentwaits

0 votes

I have this code which involves the use of fluentwait(). Can someone please explain its structure and how it works? 

Wait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);

wait.until(new com.google.common.base.Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
    return null;
}
});
Apr 13, 2018 in Selenium by kappa3010
• 2,020 points
48 views

1 answer to this question.

0 votes

Basically a FluentWait is used to define the max. amount of time you want the driver to wait for a condition. You can implement a Fluentwait like this: 

.withTimeout(60, SECONDS)

You can also set the frequency interval at which the condition will be checked. The frequency can be set like this:

.pollingEvery(5, TimeUnit.SECONDS)

You can also try to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions, which is sometimes thrown when searching for an element on the page. If you want to ignore a "NoSuchElementExceptions", then you can do it like this:

.ignoring(NoSuchElementException.class);

The best situation to use FluentWait is when your trying to test the presence of an element that may appear after every 'x' seconds/minute

answered Apr 13, 2018 by king_kenny
• 3,650 points

Related Questions In Selenium

0 votes
1 answer

Selenium IDE (2.9.1.1-signed) not working with latest Version of Firefox

Unfortunately, Selenium IDE will be deprecated soon. ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,110 points

edited Apr 4, 2018 by nsv999 3,463 views
+1 vote
1 answer

What is the working of JSON in Selenium Webdriver Architecture?

JSON stands for JavaScript Object Notation. It is used ...READ MORE

answered May 8 in Selenium by Frankie
• 9,810 points
176 views
0 votes
2 answers
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
1,006 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,153 views
0 votes
1 answer
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
343 views