Hi WDS lovers,Can You Please tell How to use FluentWait in WDS. plz give example :-) thank you in advance :-)

737 views
Skip to first unread message

Venkataswami Madala

unread,
Nov 28, 2014, 7:13:34 AM11/28/14
to jmeter-...@googlegroups.com
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
       .withTimeout(30, SECONDS)
       .pollingEvery(5, SECONDS)
       .ignoring(NoSuchElementException.class);

   WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
     public WebElement apply(WebDriver driver) {
       return driver.findElement(By.id("foo"));
     }
   });

gli...@gmail.com

unread,
Nov 28, 2014, 10:00:33 AM11/28/14
to jmeter-...@googlegroups.com
Hi Venkataswami Madala

I would like to encourage you to familiarize yourself with the Using Java From Scripts great guide. Once you master the domain you'll be able to easily convert Java code into JavaScript, vice versa and use both together. 

For particular your use case of FluentWait class usage: I don't feel myself smart enough this Friday evening to develop JavaScript code for Function inner class, however I'm still able to use ExpectedConditions as a workaround, shouldn't make much difference. Refer to code below for FluentWait class usage example in WebDriver Sampler:

var timeunit = java.util.concurrent.TimeUnit
var NSE = new java.util.NoSuchElementException
var by = org.openqa.selenium.By
var wait = new org.openqa.selenium.support.ui.FluentWait(WDS.browser).withTimeout(30, timeunit.SECONDS).pollingEvery(5, timeunit.SECONDS).ignoring(NSE.getClass());
var conditions = org.openqa.selenium.support.ui.ExpectedConditions




WDS
.browser.get("http://jmeter-plugins.org/");
wait
.until(conditions.presenceOfElementLocated(by.linkText('WebDriver Set')))

You may also wish to check The WebDriver Sampler: Your Top 10 Questions Answered guide which has similar example for WebDriverWait class and few more interesting use cases. 

Hope this helps.

Venkataswami Madala

unread,
Dec 1, 2014, 5:08:15 AM12/1/14
to jmeter-...@googlegroups.com, gli...@gmail.com
Hi, Thank you for kind reply and guidance.  i have fallowed your suggestion but "NoSuchElementException" is not working.
if i didnt find element also i want to make success.
i am trying to solve issue. but no good luck.
NSE_not_working.png

gli...@gmail.com

unread,
Dec 1, 2014, 10:38:55 AM12/1/14
to jmeter-...@googlegroups.com, gli...@gmail.com
Dear Venkataswami Madala, I apologize for giving improper answer, perhaps it is a glitch with my clipboard or so. 

Second line of the script should be 

var NSE = org.openqa.selenium.NoSuchElementException

Original sample code refers to wrong exception.

gli...@gmail.com

unread,
Dec 1, 2014, 10:40:46 AM12/1/14
to jmeter-...@googlegroups.com, gli...@gmail.com
And also change NSE.getClass() to NSE. 

Full code which is working fine:

var timeunit = java.util.concurrent.TimeUnit
var NSE = org.openqa.selenium.NoSuchElementException
var by = org.openqa.selenium.By
var wait = new org.openqa.selenium.support.ui.FluentWait(WDS.browser).withTimeout(30, timeunit.SECONDS).pollingEvery(5, timeunit.SECONDS).ignoring(NSE);

var conditions = org.openqa.selenium.support.ui.ExpectedConditions
WDS
.browser.get("http://jmeter-plugins.org/");

wait
.until(conditions.presenceOfElementLocated(by.linkText('WebDrivsdfer Set')))

kart...@gmail.com

unread,
Nov 18, 2016, 4:18:26 AM11/18/16
to jmeter-plugins
Am Getting ERROR : Cannot cast jdk.internal.dynalink.beans.StaticClass to java.lang.Clas
//var wait = new org.openqa.selenium.support.ui.FluentWait(WDS.browser).withTimeout(80, timeunit.SECONDS).pollingEvery(2, timeunit.SECONDS).ignoring(NSE);//

 plz help

Raaj K

unread,
Jun 2, 2022, 3:22:51 PM6/2/22
to jmeter-plugins
I got the same error.Making it NSE.class worked for me
var wait = new org.openqa.selenium.support.ui.FluentWait(WDS.browser).withTimeout(30, timeunit.SECONDS).pollingEvery(5, timeunit.SECONDS).ignoring(NSE.class);
Reply all
Reply to author
Forward
0 new messages