2

IE ignore zoom setting doesn't work, my code as below, why it doesn't work? I got the error message (selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. Browser zoom level was set to 125%. It should be set to 100%)

from selenium.webdriver import Ie
from selenium.webdriver.ie.options import Options
opts = Options()
opts.ignore_protected_mode_settings = True
driver = Ie(options=opts)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Johnny
  • 33
  • 1
  • 3
  • Try this, using desired caps ignore zoom setting DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true); WebDriver driver= new InternetExplorerDriver(capabilities); once page has been successfully loaded change zoom level using driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL,"0")); – Sandeep Raulo Apr 12 '18 at 12:05
  • Thanks, but I use python language. – Johnny Apr 13 '18 at 03:55
  • @sandeepraulo What can be a valid usecase to configure the _WebDriver_ instance to **ignore** the zoom settings while initialization only to change it later during the _Tests_? – undetected Selenium Apr 13 '18 at 07:44
  • @DebanjanB I tried an example from my end where even after ignoring the zoom settings selenium code was throwing either nosuchelementexception or window not in focus exception so i just tried an the mentioned code where post driver initialization it will make zoom settings to 100%. – Sandeep Raulo Apr 13 '18 at 10:34
  • @SandeepRaulo If you refer to my Answer about the documentation for _Required Configuration of InternetExplorerDriver_ mentioned in my Answer _ignoring the zoom_ will induce much havoc through different errors such as nosuchelementexception, window not in focus, etc. It's always better to follow the _Best Practices_ documented by the _IE_ team. In case you have any questions feel free to raise a ticket, SO volunteers will be glad to help you out. – undetected Selenium Apr 13 '18 at 10:47

2 Answers2

3

I faced the same issue. The option ignore_zoom_level solved it.

from selenium import webdriver
from selenium.webdriver.ie.options import Options


ie_options = Options()
ie_options.ignore_zoom_level = True
ie_driver = webdriver.Ie(options=ie_options)

See also: https://www.selenium.dev/documentation/en/driver_idiosyncrasies/driver_specific_capabilities/#internet-explorer

2

No, while working with InternetExplorerDriver you shouldn't ignore the browser zoom settings.

As per the Official Documentation of InternetExplorerDriver the Required Configuration mentions the following about Browser Zoom Level

The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

As the browser zoom level is set to 125% hence you see the error. As a solution you must set the browser zoom level back to 100%.


Update

Though you havn't replied/commented to my Answer which was constructed as per your question I can observe from your question update that you are trying to set the property ignore_protected_mode_settings to True. To achieve that you need to use an instance of DesiredCapabilities() Class and configure the WebDriver instance as follows :

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

cap = DesiredCapabilities().INTERNETEXPLORER
cap['ignoreZoomSetting'] = True
browser = webdriver.Ie(capabilities=cap, executable_path=r'C:\path\to\IEDriverServer.exe')
browser.get('http://google.com/')
browser.quit()
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks, for your answer, but I still got the same error "selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. Browser zoom level was set to 125%. It should be set to 100%" with your code. – Johnny Apr 16 '18 at 02:51
  • @Johnny The error is quite clear **zoom level was set to 125%. It should be set to 100%**. Our attempt to `ignoreZoomSetting` failed. That is what I emphasized to you in the first part of my Answer. – undetected Selenium Apr 16 '18 at 02:56
  • Got it. thanks, I set zoom setting to 100% to avoid this error by manually. thanks. – Johnny Apr 17 '18 at 04:07