2

Using the WebDriverWait feature of Selenium and trying to change the wait time. I set it to use a time of 10 seconds, but it still waits 60 seconds. I also changed the implicit wait to 120 seconds, but still 60 seconds is the time it will use. Is there another setting I'm missing? Not sure if I am doing something wrong or if there is bug in the WebDriver code. I'm also using PhantomJS as the driver. Also checked with IEDriver, same issue.

This is how WebDriverWait is being used:

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementExists(By.TagName("span")));
Saifur
  • 16,081
  • 6
  • 49
  • 73
Mike Weber
  • 311
  • 2
  • 16

1 Answers1

1

You mentioned you are using Implicit wait. If so, that could the issue since implicit wait is tied to the driver instance as long as the driver instance is not killed. And mixing implicit and explicit waits considered bad practice and can cause some unwanted result you may have missed. So, remove driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); if you are using it somewhere else after instantiating the driver

Saifur
  • 16,081
  • 6
  • 49
  • 73
  • Yup - that was the ticket!! I did have the Implicit wait set for 120 seconds, and removed that. However, the implicit wait still did not change the wait time from 60 to 120 seconds - so that is still an issue. – Mike Weber Apr 03 '15 at 18:29
  • So you are having issue with `explicit` or `implicit` wait? – Saifur Apr 03 '15 at 18:34
  • Both. I had an ImplicitlyWait command as well as the WebDriverWait. When I removed the ImplicitlyWait command, then the WebDriverWait behaved as expected. However, when removing the WebDriverWait and re-adding the ImplicitlyWait command (set for 120 seconds), the wait time is still at 60 seconds. Hopefully I explained that clearly. – Mike Weber Apr 06 '15 at 14:33
  • Don't use ImplicitlyWait (don't have a reason, just have never used it). Implicit waits work fine when you use driver.Manage() rather than the ImplicityWait command. – aholt Apr 06 '15 at 19:17
  • @aholt - not sure what you mean to use driver.Manage() vs. ImplicitlyWait. If I run a test without the ImplicitWait, the driver returns immediately - and the element is not found since it is intentionally not there due to trying to figure out the timeouts. – Mike Weber Apr 06 '15 at 22:26
  • Turns out anything less than 1 minute will work - driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(.5)); - this waits 30 seconds. Anything over 1 minute will default to 60 seconds is my finding. – Mike Weber Apr 06 '15 at 22:43
  • Ahh.. Good to know. Did you find the doc or you tested? – Saifur Apr 06 '15 at 22:50
  • 1
    Tested. Did not find anything in the docs that indicate an upper limit. – Mike Weber Apr 08 '15 at 23:27
  • @MikeWeber See [this](http://stackoverflow.com/questions/29474296/clarification-on-the-cause-of-mixing-implicit-and-explicit-waits-in-selenium-doc) you may find this interesting as well – Saifur Apr 08 '15 at 23:28