繁体   English   中英

InPrivate模式下Internet Explorer中的Selenium测试

[英]Selenium test in Internet Explorer in InPrivate mode

有没有办法如何使用IEDriverServer在InPrivate模式下在Internet Explorer 9中运行Selenium自动化测试? 我需要测试2个(两个)测试用例:
1.浏览器已关闭。 打开IE InPrivate模式的一个窗口。 运行测试。
2.浏览器在正常模式下打开。 打开IE InPrivate模式的新窗口。 运行测试。

JAVA代码应该如何查找此测试?
谢谢

public void openBrowserInPrivacyMode(boolean isBrowserActive) {
    System.setProperty("webdriver.ie.driver", "path/to/IEDriverServer_x32.exe"); 
    DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();  
    capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);  
    сapabilities.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private");
    InternetExplorerDriver driver = new InternetExplorerDriver(capabilities);

@ Roman的解决方案现已弃用

新的方法如下:

InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
ieOptions.addCommandSwitches("-private");
InternetExplorerDriver driver = InternetExplorerDriver(ieOptions));

此外,我在执行此操作时遇到问题,直到我设置了TabProcGrowth注册表值。 在此之前我得到以下异常:

org.openqa.selenium.SessionNotCreatedException: Unexpected error launching Internet Explorer.
Unable to use CreateProcess() API. To use CreateProcess() with Internet Explorer 8 or higher,
the value of registry setting in
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0'.

我在Windows 10和Selenium 3.14中遇到过这种情况。 奇怪的是,设置TabProcGrowth值也为我解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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