How to ignore zoom setting
Asked Answered
S

2

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)
Selfseeker answered 12/4, 2018 at 5:57 Comment(5)
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"));U
Thanks, but I use python language.Selfseeker
@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?Rustcolored
@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%.U
@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.Rustcolored
R
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()
Rustcolored answered 12/4, 2018 at 6:6 Comment(3)
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.Selfseeker
@Selfseeker 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.Rustcolored
Got it. thanks, I set zoom setting to 100% to avoid this error by manually. thanks.Selfseeker
S
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

Signpost answered 14/7, 2021 at 20:30 Comment(0)
R
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()
Rustcolored answered 12/4, 2018 at 6:6 Comment(3)
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.Selfseeker
@Selfseeker 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.Rustcolored
Got it. thanks, I set zoom setting to 100% to avoid this error by manually. thanks.Selfseeker

© 2022 - 2024 — McMap. All rights reserved.