[唐胡璐]Selenium技巧- IE浏览器Zoom和Protected Model Setting
Selenium Webdriver在IE下跑脚本的时候要保证页面大小为100%,且要在IE internet options, selectSecurity tab and uncheck “Enable Protected Mode” for all security zone.
为了不手动来做这些设置,我们可以在Launch IE Driver的时候控制,如下:
1 2 3 4 5 6 7 8 9 10 | System.setProperty( "webdriver.ie.driver" , "resource\\IEDriverServer.exe" ); DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); //zoom ieCapabilities.setCapability( "ignoreZoomSetting" , true ); //Security ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true ); WebDriver driver = new InternetExplorerDriver(ieCapabilities); |