3

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?

2 Answers 2

3

Try some of these:

driver.manage().timeouts().implicitlyWait()
driver.manage().timeouts().setScriptTimeout()
Sign up to request clarification or add additional context in comments.

2 Comments

hum implicitlyWait() actually worked, do u have any idea why the WebDriverWait method did not?
yes. WebDriverWait did not work because you are calling elementToBeClickable. I think might have wanted wait.until(ExpectedConditions.not(ExpectedConditions.invisiblilityOfElementLocated(By.id("someid")));
2

Wait for 10 sec in Selenium WedDriver with Java:

For Implicit wait:

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

For Explicit wait:

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("someID")));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.