Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium WebDriver with Java NoSuchElementException timeout

I have a problem with the timeout time of the NoSuchElementException, it seem to be 30 seconds by default and I want to shorten it down. So I wrote something like this:

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
element.click();

And I get this message:

org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for element to be
clickable: By.id: someid

org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: 
{"method":"id","selector":"someid"}
Command duration or timeout: 30.03 seconds

So the first message is what I was hoping that the WebDriverWait would override the NoSuchElementException timeout but I still get the full 30 seconds. Anyway, what's the way to get rid of this?

like image 831
user1593846 Avatar asked Sep 16 '26 10:09

user1593846


1 Answers

Try some of these:

driver.manage().timeouts().implicitlyWait()
driver.manage().timeouts().setScriptTimeout()
like image 99
stan Avatar answered Sep 18 '26 22:09

stan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!