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

588 views
Skip to first unread message

Vamshi Potu

unread,
Mar 25, 2020, 6:13:44 AM3/25/20
to Selenium Users
I am having an issue with .withTimeout(30, TimeUnit.SECONDS) can any one please suggest me.

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

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;

public class FluentWaitExample {

public static void main(String[] args) {

System.setProperty("webdriver.gecko.driver","D:\\Softwares\\Selenium\\geckodriver.exe");
FirefoxDriver driver=new FirefoxDriver();
driver.get("https://www.google.co.in");
WebElement element1=driver.findElement(By.xpath("/html/body/div/div[3]/form/div[2]/div[1]/div[1]/div/div[2]/input"));
   Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
       .withTimeout(30, TimeUnit.SECONDS)
       .pollingEvery(5, TimeUnit.SECONDS)
       .ignoring(NoSuchElementException.class);

   WebElement element = wait.until(ExpectedConditions.visibilityOf(element1));
}

}

Kogul S

unread,
Mar 25, 2020, 2:26:39 PM3/25/20
to seleniu...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/1d79e091-72af-4278-a852-cf9cd99910c6%40googlegroups.com.

Vamshi Potu

unread,
Mar 26, 2020, 12:30:13 PM3/26/20
to seleniu...@googlegroups.com
Hello Kogul

Thank you for your response and solution.


John Pulwers

unread,
Mar 26, 2020, 1:01:57 PM3/26/20
to seleniu...@googlegroups.com
What an elegant statement. Could someone please explain in detail what it does, specifically? I can see it waits up to 30 seconds for an element to be displayed on the Google website with the FireFox browser? Question is: Can I use this for any element that is found with the XPath or CSS Selector?

Reply all
Reply to author
Forward
0 new messages