简体   繁体   中英

Selenium with Edge in IE Compatability Mode - Private

I am using Selenium's InternetExplorerDriver to run Edge in IE Compatibility Mode. What I would like to do is have Edge open "InPrivate".

When targeting IE itself, we can set the InternetExplorerOptions.BrowserCommandLineArguments = "-private" to get a private window. How do we do this when targeting Edge in IE Compatibility Mode with the InternetExplorerDriver?

Thanks

You can try like the below

InternetExplorerDriverService ieService = InternetExplorerDriverService.createDefaultService();

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setAcceptInsecureCerts(false);
    caps.setBrowserName("internet explorer");
    caps.setCapability("ie.edgechromium", true);
    System.out.println("caps.getBrowserName() = " + caps.getBrowserName());
    System.out.println("caps browserName = " + caps.getCapability("browserName"));
    caps.setCapability("ie.edgepath", "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");

    InternetExplorerOptions options = new InternetExplorerOptions();
    options.enablePersistentHovering();
    options.ignoreZoomSettings();
    options.requireWindowFocus();
    options.setCapability("ignoreProtectedModeSettings", true);
    WebDriver driver = new InternetExplorerDriver(ieService, options.merge(caps));
    driver.manage().window().maximize();
    driver.get("https://github.com");

if this launch the Internet Explor er, then one of the prerequisites is to enable IE11 .

Just refer to this doc: Edge IE mode-Prerequisites .

And as far as I know, IEdriver will start any version of IE installed in the machine, when Edge IE mode conditions are not met, it will not launch Edge, but default Internet Explorer.

So you could upgrade the version of IE to 11 . I think this should make it work.

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