简体   繁体   中英

Selenium not able to identify elements on newly opened browser in IE

In IE browser, On clicking one of the links, a new browser is opening up but selenium is not able to move control to the new browser and not detecting any elements in the new browser.

I am using these IE settings.

InternetExplorerOptions option = new InternetExplorerOptions();
        option.setCapability(CapabilityType.BROWSER_NAME, "internet explorer");
        option.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
        option.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
        option.setCapability(InternetExplorerDriver.UNEXPECTED_ALERT_BEHAVIOR,UnexpectedAlertBehaviour.IGNORE);
        option.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS,true);
        option.setCapability("ignoreProtectedModeSettings", true);

        option.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "normal");
        option.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

        option.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);

I have these security settings of IE brower and I cannot change these settings because of company restrictions. Protected Mode is enabled for 'Internet' & 'Restricted Site' and it's not enabled for 'Local IntRANET & 'TRUSTED sites'.

Anyone has any other way to handle this issue?

Excerpt from InternetExplorerDriver documentation:

Required Configuration: "On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode"."

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

Unless the protected mode setting is same for all four zones, switching to new window won't work. I ran into this issue couple of months back, and there is no way as of today to switch to new window unless the protected mode settings are done per the documentation referenced above.

I got this working by procuring a Test machine specifically for running Automation scripts (we are using Selenium Grid in my organization) and set the same protected mode settings for all four zones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM