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,010 points
28 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,590 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,030 points

edited Apr 4, 2018 by nsv999 2,105 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,570 points
9 views
0 votes
1 answer

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

We can take screenshots using below function ...READ MORE

answered Mar 23, 2018 in Selenium by nsv999
• 5,030 points
108 views
0 votes
1 answer
0 votes
1 answer

Need to wait until page is completely loaded - Selenium WebDriver

Using Thread.Sleep(); is one approach; but its ...READ MORE

answered Apr 2, 2018 in Selenium by nsv999
• 5,030 points
2,325 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,030 points
56 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
420 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,590 points
124 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.