MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / GetCurrentUrl

Method GetCurrentUrl

cpp/iedriver/DocumentHost.cpp:79–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79std::string DocumentHost::GetCurrentUrl() {
80 LOG(TRACE) << "Entering DocumentHost::GetCurrentUrl";
81
82 CComPtr<IHTMLDocument2> doc;
83 this->GetDocument(&doc);
84 if (!doc) {
85 LOG(WARN) << "Unable to get document object, DocumentHost::GetDocument returned NULL. "
86 << "Attempting to get URL from IWebBrowser2 object";
87 return this->GetBrowserUrl();
88 }
89
90 CComBSTR url;
91 HRESULT hr = doc->get_URL(&url);
92 if (FAILED(hr)) {
93 LOGHR(WARN, hr) << "Unable to get current URL, call to IHTMLDocument2::get_URL failed";
94 return "";
95 }
96
97 std::wstring converted_url(url, ::SysStringLen(url));
98 std::string current_url = StringUtilities::ToString(converted_url);
99 return current_url;
100}
101
102std::string DocumentHost::GetPageSource() {
103 LOG(TRACE) << "Entering DocumentHost::GetPageSource";

Callers 5

ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80

Calls 3

LOGClass · 0.50
GetDocumentMethod · 0.45
GetBrowserUrlMethod · 0.45

Tested by

no test coverage detected