Selenium Framework for Beginners 30 | What is fluent wait | How to use fluent wait in Selenium

  • 🎬 Video
  • ℹ️ Published 4 years ago
preview_player
UCTt7pyY-o0eltq14glaG5dg

Today we will learn
1 What is fluent wait
2 How to use fluent wait

What is fluent wait
Fluent Wait - a class in Selenium api

When you want to:
apply wait to specific element
set max wait time period
set polling frequency
set to ignore specific exceptions

Syntax :

Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)

Syntax for Selenium 4:
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)

Why we use waits
The elements load time on a web page can vary

Not all the elements are loaded at the same time

In applications developed using Ajax, Javascript etc, objects on web page may load at different time

To handle this, we need to use waits in Selenium

With the help of waits, we can enable the script to wait for sometime before throwing No Such Element exception


REFERENCES



#SeleniumFluentWait #SeleniumBeginnerTutorials

PLAYLISTS

SELENIUM JAVA FRAMEWORK BEGINNERS

KATALON STUDIO

SELENIUM BEGINNERS

SELENIUM TIPS

SELENIUM PYTHON

SELENIUM BUILDER

JAVA

JAVA TIPS & TRICKS

JENKINS

JENKINS TIPS & TRICKS

JMETER BEGINNER

JMETER INTERMEDIATE

JMETER ADVANCED

JMETER TIPS & TRICKS

SOAPUI

POSTMAN

GIT & GITHUB

DOCKER

ROBOT FRAMEWORK

WEB SERVICES (API)

REDIS BEGINNER TUTORIALS

MAVEN

MISC

TOOLS & TIPS

QnA FRIDAY

SUNDAY SPECIAL

ALL PLAYLISTS

Like on FACEBOOK :

Follow on TWITTER:

Subscribe on YOUTUBE :

Like, Subscribe & Share
You can support my mission for education by sharing this knowledge and helping as many people as you can

Never Stop Learning
Raghav

💬 Comments
Author

In Selenium 4.0, we have to use "Java.time.duration", so the wait method would be

Author — yikai zhu

Author

Hi Raghav, I am getting the following error with FluentWait, "The type FluentWait is not generic; it cannot be parameterized with arguments <WebDriver>" and I am selenium 3.12. Can you please advise. Thank you in advance.

Author — PITUMBUR VIVEKANAND

Author

Hi Raghav,
Which version of selenium are you using?
I'm getting methods depreciated warning for version 3.14.0.
I used 2.53.0 but the browser is closing very soon.

Author — Zamir Khan

Author

What is difference between WebDriverWait and FluentWait ?
I feel WebDriverWait does same task with less lines of code.

Author — Wilson Fernandes

Author

Hi Raghav could you explain how to write fluent wait code in typescript?

Author — Saraswati Hulagannavar

Author

This reminds me CompletableFeature from Java threads :D I find it similar in some ways.

Author — Bartłomiej Kmita

Author

"withTimeout(10, TimeUnit.Seconds)" and PollingEvery(2, TimeUnit.Seconds)" getting error that it is deprecated after Selenium v3.11.0. Using and will work now. Import Java.time.Duration

Author — Rahul Dubey

Author

Wait<WebDriver> wait = new
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)


I got error here as well
It didn't work saying WebDriverWait deprecated in Selenium 4.0.0-alpha-3. as I am using selenium-java version 4.0.0-alpha-5

Later I found out that
Wait<WebDriver> wait = new



There is change in syntax n it worked for me
Hope this works for someone

Thanks in advance
Hima

Author — Hima

Author

Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(5, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)

WebElement foo = wait.until(new Function<WebDriver, WebElement>() {

public WebElement apply(WebDriver driver) {
return
}
});


Error is
The method withTimeout(Duration) in the type FluentWait<WebDriver> is not applicable for the arguments (int, TimeUnit)


please Help

Author — Ashwini Lohar

Author

What is the problem if we use click
.rether than sendkeys.return. can you plz.explain
Thanks

Author — faisal sakib

Author

How you getting auto suggestion of code in eclipse, I am not getting in auto suggestion, if I am moving my mouse to those classes and methods.

Author — HuzzuTech

Author

In want to apply fluent wait irrespective of all elements... how to achieve that??

Author — Manikandan M

Author

How does he is able to click on a link of page 2 from page 1?

Author — Vamsi Prasad Kumili

Author

Sir @15:48, if u don't click on manually on page 2, Is our script automatically goto page 2 and click that required link🤔???

Author — Alok Sharma