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

Method GetBrowserZoomLevel

cpp/iedriver/BrowserFactory.cpp:738–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738int BrowserFactory::GetBrowserZoomLevel(IWebBrowser2* browser) {
739 LOG(TRACE) << "Entering BrowserFactory::GetBrowserZoomLevel";
740 clock_t end = clock() + (this->browser_attach_timeout_ / 1000 * CLOCKS_PER_SEC);
741 CComPtr<IDispatch> document_dispatch;
742 while (!document_dispatch) {
743 if (this->browser_attach_timeout_ > 0 && (clock() > end)) {
744 break;
745 }
746
747 browser->get_Document(&document_dispatch);
748
749 if (!document_dispatch) {
750 ::Sleep(250);
751 }
752 }
753
754 if (!document_dispatch) {
755 LOG(WARN) << "Call to IWebBrowser2::get_Document failed";
756 return 0;
757 }
758
759 CComPtr<IHTMLDocument2> document;
760 document_dispatch->QueryInterface(&document);
761 if (!document) {
762 LOG(WARN) << "QueryInterface for IHTMLDocument2 failed.";
763 return 0;
764 }
765
766 CComPtr<IHTMLWindow2> window;
767 HRESULT hr = document->get_parentWindow(&window);
768 if (FAILED(hr)) {
769 LOGHR(WARN, hr) << "Call to IHTMLDocument2::get_parentWindow failed";
770 return 0;
771 }
772
773 // Test for zoom level = 100%
774 int zoom_level = this->GetZoomLevel(document, window);
775 return zoom_level;
776}
777
778int BrowserFactory::GetZoomLevel(IHTMLDocument2* document, IHTMLWindow2* window) {
779 LOG(TRACE) << "Entering BrowserFactory::GetZoomLevel";

Callers 1

AttachToBrowserMethod · 0.95

Calls 2

GetZoomLevelMethod · 0.95
LOGClass · 0.50

Tested by

no test coverage detected