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

Method GetWindowName

cpp/iedriver/Browser.cpp:352–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352std::string Browser::GetWindowName() {
353 LOG(TRACE) << "Entering Browser::GetWindowName";
354
355 CComPtr<IDispatch> dispatch;
356 HRESULT hr = this->browser_->get_Document(&dispatch);
357 if (FAILED(hr)) {
358 LOGHR(WARN, hr) << "Unable to get document, IWebBrowser2::get_Document call failed";
359 return "";
360 }
361
362 CComPtr<IHTMLDocument2> doc;
363 dispatch->QueryInterface<IHTMLDocument2>(&doc);
364 if (!doc) {
365 LOGHR(WARN, hr) << "Have document but cannot cast, IDispatch::QueryInterface call failed";
366 return "";
367 }
368
369 CComPtr<IHTMLWindow2> window;
370 hr = doc->get_parentWindow(&window);
371 if (FAILED(hr)) {
372 LOGHR(WARN, hr) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed";
373 return "";
374 }
375
376 std::string name = "";
377 CComBSTR window_name;
378 hr = window->get_name(&window_name);
379 if (window_name) {
380 std::wstring converted_window_name = window_name;
381 name = StringUtilities::ToString(converted_window_name);
382 } else {
383 LOG(WARN) << "Unable to get window name, IHTMLWindow2::get_name failed or returned a NULL value";
384 }
385
386 return name;
387}
388
389long Browser::GetWidth() {
390 LOG(TRACE) << "Entering Browser::GetWidth";

Callers

nothing calls this directly

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected