Skip to content
This repository has been archived by the owner. It is now read-only.

WebDriverWait uses Implicit wait duration instead #4471

Closed
lukeis opened this issue Mar 4, 2016 · 3 comments
Closed

WebDriverWait uses Implicit wait duration instead #4471

lukeis opened this issue Mar 4, 2016 · 3 comments

Comments

@lukeis
Copy link
Member

@lukeis lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 4471


What steps will reproduce the problem?
1. Run the attached program
2. View the console output


What is the expected output? What do you see instead?
Expected output is something like: 

Implicit wait: Find element took 3.148129654 s
Explicit wait: Find element took 3.160037161 s
Explicit and implicit wait: Find element took 3.136456231 s

Instead it is more like: 
Implicit wait: Find element took 3.148129654 s
Explicit wait: Find element took 3.160037161 s
Explicit and implicit wait: Find element took 6.136456231 s

Selenium version: 2.25.0
OS: Windows 7
Browser: Program uses Firefox but browser is irrelevant to behavior
Browser version: 14.0.1


Please provide any additional information below. 

The attachment is a simple program that displays three cases: a WebDriver with an implicit
wait set, a WebDriver without an implicit wait being used by a WebDriverWait, and a
WebDriver with an implicit wait and being used by a WebDriverWait. In the last case,
the implicit wait is *higher* than the duration set on the WebDriverWait. In each case,
the WebDriver will go to google and try to find an element that is not present, so
it will trigger whichever form of waiting is active. In the third case though, the
longer implicit wait is used, meaning the duration set in the constructor of the WebDriverWait
is essentially meaningless. 

If the implicit wait is lower than the WebDriverWait's duration, then the behavior
is as expected, it's when the implicit wait is higher that it becomes a problem.

Reported by smith.6606 on 2012-08-27 17:50:59


- _Attachment: [ImplicitWaitTest.java](https://storage.googleapis.com/google-code-attachments/selenium/issue-4471/comment-0/ImplicitWaitTest.java)_
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

We recommend never combining implicit and explicit waits because of confusing cases
such as this.  Setting the implicit wait changes state on the WebDriver server, forcing
a wait on every findElement/findElements call (hence the name "implicit wait").

Explicit waits are a pure-client side construct that involves polling until some condition
is met.  If you have implicit waits enabled, any findElement commands inside your explicit
wait will be subject to its timeout.

Reported by jmleyba on 2012-08-31 15:12:36

  • Status changed: WorkingAsIntended
  • Labels added: Component-WebDriver
  • Labels removed: Status-Untriaged
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I agree combining them is never a good idea, however this is often a problem with PageObjects
that may be using WebDriverWait. The page object has no access to any implicit waits
that may be set on the WebDriver it receives--besides setting it to a new value, it
can't get the previous one, per issue 2227. I don't know if it's a good practice to
have a page object alter the state of the WebDriver it's given (except what page the
WebDriver was on, obviously), but I suppose that's necessary in this case. 

Thanks for the explanation!

Reported by smith.6606 on 2012-08-31 15:35:49

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:02

  • Labels added: Restrict-AddIssueComment-Commit
@lukeis lukeis closed this Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.