Skip to content

Commit

Permalink
Make IE wait algorithm respect load strategy for IWebBrowser2::ReadyS…
Browse files Browse the repository at this point in the history
…tate

Prior to this commit, the driver would only respect the page load strategy
for document.readyState, not for the browser COM object. This means that,
for example, when IE has an info bar being displayed (like when
downloading a file), the driver will wait indefinitely, since the
IWebBrowser2 object's ReadyState property will never cycle over to
"complete," topping out at "interactive."

Fixes issue #999.
Fixes issue #1843.
  • Loading branch information
jimevans committed Mar 24, 2016
1 parent 8f45509 commit fa5ac92
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cpp/iedriver/Browser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,22 @@ bool Browser::Wait(const std::string& page_load_strategy) {
return false;
}

// Waiting for browser.ReadyState == READYSTATE_COMPLETE...;
READYSTATE expected_ready_state = READYSTATE_COMPLETE;
if (page_load_strategy == "eager") {
expected_ready_state = READYSTATE_INTERACTIVE;
}

// Waiting for browser.ReadyState >= expected ready state
is_navigating = this->is_navigation_started_;
READYSTATE ready_state;
HRESULT hr = this->browser_->get_ReadyState(&ready_state);
if (is_navigating || FAILED(hr) || ready_state != READYSTATE_COMPLETE) {
if (is_navigating || FAILED(hr) || ready_state < expected_ready_state) {
if (is_navigating) {
LOG(DEBUG) << "DocumentComplete event fired, indicating a new navigation.";
} else if (FAILED(hr)) {
LOGHR(DEBUG, hr) << "IWebBrowser2::get_ReadyState failed.";
} else {
LOG(DEBUG) << "Browser ReadyState is not '4', indicating 'Complete'; it was " << ready_state;
LOG(DEBUG) << "Browser ReadyState is not at least '" << expected_ready_state << "'; it was " << ready_state;
}
return false;
}
Expand Down
11 changes: 11 additions & 0 deletions cpp/iedriverserver/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ available via the project downloads page. Changes in "revision" field indicate
private releases checked into the prebuilts directory of the source tree, but
not made generally available on the downloads page.

v2.53.0.1
=========
* Modified wait algorithm to respect page load strategy for
IWebBrowser2::ReadyState. Prior to this commit, the driver would only
respect the page load strategy for document.readyState, not for the
browser COM object. This means that, for example, when IE has an info
bar being displayed (like when downloading a file), the driver will wait
indefinitely, since the IWebBrowser2 object's ReadyState property will
never cycle over to "complete," topping out at "interactive." Fixes issues
#999 and #1843.

v2.53.0.0
=========
* Release to synchronize with release of Selenium project.
Expand Down
Binary file modified cpp/iedriverserver/IEDriverServer.rc
Binary file not shown.
Binary file modified cpp/prebuilt/Win32/Release/IEDriverServer.exe
Binary file not shown.
Binary file modified cpp/prebuilt/x64/Release/IEDriverServer.exe
Binary file not shown.

0 comments on commit fa5ac92

Please sign in to comment.