Skip to content

Commit d249232

Browse files
committed
Updating IE to return top-level URL when focused on a frame.
This makes the driver now consistent with other implementations.
1 parent a1da99a commit d249232

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

cpp/iedriver/CommandHandlers/GetCurrentUrlCommandHandler.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,21 @@ class GetCurrentUrlCommandHandler : public IECommandHandler {
4343
return;
4444
}
4545

46-
std::string url = browser_wrapper->GetCurrentUrl();
47-
response->SetSuccessResponse(url);
46+
CComPtr<IHTMLDocument2> top_level_document;
47+
browser_wrapper->GetDocument(true, &top_level_document);
48+
if (!top_level_document) {
49+
LOG(WARN) << "Unable to get document from browser. Are you viewing a non-HTML document?";
50+
}
51+
52+
CComBSTR url;
53+
HRESULT hr = top_level_document->get_URL(&url);
54+
if (FAILED(hr)) {
55+
LOGHR(WARN, hr) << "IHTMLDocument2::get_URL failed.";
56+
}
57+
58+
std::wstring converted_url(url, ::SysStringLen(url));
59+
std::string current_url = StringUtilities::ToString(converted_url);
60+
response->SetSuccessResponse(current_url);
4861
}
4962
};
5063

cpp/iedriver/DocumentHost.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ std::string DocumentHost::GetCurrentUrl() {
8383
return "";
8484
}
8585

86-
std::wstring converted_url = url;
86+
std::wstring converted_url(url, ::SysStringLen(url));
8787
std::string current_url = StringUtilities::ToString(converted_url);
8888
return current_url;
8989
}

cpp/iedriverserver/CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ 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.48.0.1
13+
=========
14+
* Updating to return top-level URL when focused on a frame. This makes the
15+
driver now consistent with other implementations.
16+
1217
v2.48.0.0
1318
=========
1419
* Release to synchronize with release of Selenium project.
0 Bytes
Binary file not shown.
1 KB
Binary file not shown.
1.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)