[英]Selenium test in Internet Explorer in InPrivate mode
Is there any way how to run Selenium automation test in Internet Explorer 9 in InPrivate mode with IEDriverServer? 有没有办法如何使用IEDriverServer在InPrivate模式下在Internet Explorer 9中运行Selenium自动化测试? I need to test 2 (two) testcases: 我需要测试2个(两个)测试用例:
1. browser is closed. 1.浏览器已关闭。 Open one window of IE InPrivate mode. 打开IE InPrivate模式的一个窗口。 Run test. 运行测试。
2. browser is opened in normal mode. 2.浏览器在正常模式下打开。 Open new window of IE InPrivate mode. 打开IE InPrivate模式的新窗口。 Run test. 运行测试。
How should JAVA code look for this tests? JAVA代码应该如何查找此测试?
Thank you 谢谢
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's solution is now deprecated . @ Roman的解决方案现已弃用 。
The new way to do this is as follows: 新的方法如下:
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
ieOptions.addCommandSwitches("-private");
InternetExplorerDriver driver = InternetExplorerDriver(ieOptions));
Also, I had problems doing this, until I set a TabProcGrowth registry value. 此外,我在执行此操作时遇到问题,直到我设置了TabProcGrowth注册表值。 Before doing this I got the following exception: 在此之前我得到以下异常:
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'.
I had this with happening with Windows 10 and Selenium 3.14. 我在Windows 10和Selenium 3.14中遇到过这种情况。 Curiously enough, setting the TabProcGrowth value also fixed this for me. 奇怪的是,设置TabProcGrowth值也为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.