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,090 points
393 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,500 points

edited Apr 4, 2018 by nsv999 7,181 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,830 points
3,065 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 23, 2019 in Selenium by Abha
• 28,140 points
974 views
0 votes
1 answer
+1 vote
4 answers

Need to wait until page is completely loaded - Selenium WebDriver

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

answered Dec 21, 2019 in Selenium by Robin
63,307 views
0 votes
2 answers

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,500 points
12,620 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
8,572 views
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,910 points
6,629 views
0 votes
1 answer
0 votes
2 answers

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

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

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,487 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP