[英]Selenium with Edge in IE Compatability Mode - Private
我正在使用 Selenium 的 InternetExplorerDriver 在 IE 兼容模式下运行 Edge。 我想做的是让Edge打开“InPrivate”。
当针对 IE 本身时,我们可以设置InternetExplorerOptions.BrowserCommandLineArguments = "-private"
来获得一个私有窗口。 当使用 InternetExplorerDriver 在 IE 兼容模式下定位 Edge 时,我们如何做到这一点?
谢谢
您可以尝试如下
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");
如果此启动Internet Explorer ,则先决条件之一是启用IE11 。
只需参考此文档: Edge IE mode-Prerequisites 。
而且据我所知, IEdriver
会启动机器上安装的任何版本的 IE,当不满足 Edge IE 模式条件时,它不会启动 Edge,而是默认启动 Internet Explorer。
因此,您可以将IE的版本升级到11 。 我认为这应该使它起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.