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

Method GetTitle

cpp/iedriver/Browser.cpp:270–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270std::string Browser::GetTitle() {
271 LOG(TRACE) << "Entering Browser::GetTitle";
272
273 CComPtr<IDispatch> dispatch;
274 HRESULT hr = this->browser_->get_Document(&dispatch);
275 if (FAILED(hr)) {
276 LOGHR(WARN, hr) << "Unable to get document, IWebBrowser2::get_Document call failed";
277 return "";
278 }
279
280 CComPtr<IHTMLDocument2> doc;
281 hr = dispatch->QueryInterface(&doc);
282 if (FAILED(hr)) {
283 LOGHR(WARN, hr) << "Have document but cannot cast, IDispatch::QueryInterface call failed";
284 return "";
285 }
286
287 CComBSTR title;
288 hr = doc->get_title(&title);
289 if (FAILED(hr)) {
290 LOGHR(WARN, hr) << "Unable to get document title, call to IHTMLDocument2::get_title failed";
291 return "";
292 }
293
294 std::wstring converted_title = title;
295 std::string title_string = StringUtilities::ToString(converted_title);
296 return title_string;
297}
298
299std::string Browser::GetBrowserUrl() {
300 LOG(TRACE) << "Entering Browser::GetBrowserUrl";

Callers 1

ExecuteInternalMethod · 0.45

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected