Mohamed Elgamal
Mohamed Elgamal

Reputation: 3

the method withtimeout(duration) in the type fluentwait<webdriver> is not applicable for the arguments (int, timeunit)

An error appear while working with this code the error is

"The method withTimeout(Duration) in the type FluentWait is not applicable for the arguments (int, TimeUnit)"

Wait wait = new FluentWait(driver)    
    .withTimeout(30, SECONDS)    
    .pollingEvery(5, SECONDS)   
    .ignoring(NoSuchElementException.class);

Upvotes: 0

Views: 6746

Answers (3)

Kapil Sharma
Kapil Sharma

Reputation: 31

Following work with one condition, variable name should be anything instead of "wait" , i.e. "wait1" would work

#CompleteWaitCode

@SuppressWarnings("unchecked")
Wait **wait1** = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30)).ignoring(NoSuchElementException.class);
        
@SuppressWarnings("unchecked")
WebElement element = (WebElement) wait1.until(new Function<WebDriver, WebElement>() {
           
public WebElement apply(WebDriver arg0) {
WebElement linkelement = driver.findElement(By.cssSelector("button[class='btn btn-primary']"));

if (linkelement.isEnabled()) {
      System.out.println("Element is Found");
                }
 return linkelement;
      }
});

Upvotes: 0

Mohamed Elgamal
Mohamed Elgamal

Reputation: 3

I searched and the following code worked for me

            Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
                .withTimeout(10, TimeUnit.SECONDS)
                .pollingEvery(2, TimeUnit.SECONDS)
                .ignoring(NoSuchElementException.class);

Upvotes: 0

Arun Nair
Arun Nair

Reputation: 478

This is the correct usage now..

Wait wait = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30))
                    .ignoring(NoSuchElementException.class);

Upvotes: 2

Related Questions