Skip to content

Commit fa5ac92

Browse files
committed
Make IE wait algorithm respect 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 issue #999. Fixes issue #1843.
1 parent 8f45509 commit fa5ac92

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

cpp/iedriver/Browser.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,17 +460,22 @@ bool Browser::Wait(const std::string& page_load_strategy) {
460460
return false;
461461
}
462462

463-
// Waiting for browser.ReadyState == READYSTATE_COMPLETE...;
463+
READYSTATE expected_ready_state = READYSTATE_COMPLETE;
464+
if (page_load_strategy == "eager") {
465+
expected_ready_state = READYSTATE_INTERACTIVE;
466+
}
467+
468+
// Waiting for browser.ReadyState >= expected ready state
464469
is_navigating = this->is_navigation_started_;
465470
READYSTATE ready_state;
466471
HRESULT hr = this->browser_->get_ReadyState(&ready_state);
467-
if (is_navigating || FAILED(hr) || ready_state != READYSTATE_COMPLETE) {
472+
if (is_navigating || FAILED(hr) || ready_state < expected_ready_state) {
468473
if (is_navigating) {
469474
LOG(DEBUG) << "DocumentComplete event fired, indicating a new navigation.";
470475
} else if (FAILED(hr)) {
471476
LOGHR(DEBUG, hr) << "IWebBrowser2::get_ReadyState failed.";
472477
} else {
473-
LOG(DEBUG) << "Browser ReadyState is not '4', indicating 'Complete'; it was " << ready_state;
478+
LOG(DEBUG) << "Browser ReadyState is not at least '" << expected_ready_state << "'; it was " << ready_state;
474479
}
475480
return false;
476481
}

cpp/iedriverserver/CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ available via the project downloads page. Changes in "revision" field indicate
99
private releases checked into the prebuilts directory of the source tree, but
1010
not made generally available on the downloads page.
1111

12+
v2.53.0.1
13+
=========
14+
* Modified wait algorithm to respect page load strategy for
15+
IWebBrowser2::ReadyState. Prior to this commit, the driver would only
16+
respect the page load strategy for document.readyState, not for the
17+
browser COM object. This means that, for example, when IE has an info
18+
bar being displayed (like when downloading a file), the driver will wait
19+
indefinitely, since the IWebBrowser2 object's ReadyState property will
20+
never cycle over to "complete," topping out at "interactive." Fixes issues
21+
#999 and #1843.
22+
1223
v2.53.0.0
1324
=========
1425
* Release to synchronize with release of Selenium project.

cpp/iedriverserver/IEDriverServer.rc

0 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.
-512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)