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,080 points
89 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,710 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,510 points

edited Apr 4, 2018 by nsv999 4,902 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, 2019 in Selenium by Frankie
• 9,810 points
949 views
0 votes
2 answers

How can we take screenshots of tests in Selenium 2 using C#

Hey, try using following code command to ...READ MORE

answered Aug 22, 2019 in Selenium by Abha
• 27,910 points
284 views
0 votes
1 answer
+1 vote
3 answers

Need to wait until page is completely loaded - Selenium WebDriver

You can try something like -  new WebDriverWait(firefoxDriver, ...READ MORE

answered Dec 20, 2019 in Selenium by Robin
18,535 views
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,510 points
2,937 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,890 points
2,250 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,710 points
718 views