简体   繁体   English

InPrivate模式下Internet Explorer中的Selenium测试

[英]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.

相关问题 selenium 未检测到 firefox 中的链接,但相同的测试在 Internet Explorer 中运行良好 - selenium not detecting a link in firefox but same test runs fine in internet explorer Selenium 在 IE 模式下无法找到新的 window 句柄,但在正常模式下工作(Internet Explorer)| Selenium 版本 4.3.0.0 - Selenium not able to find new window handle in IE MODE but working in normal mode ( internet explorer ) | Selenium version 4.3.0.0 Internet Explorer中的Selenium Webdriver - Selenium Webdriver in Internet explorer Selenium:Internet Explorer中的NoSuchElementException - Selenium: NoSuchElementException in Internet Explorer Zk 6:兼容模式下的Internet Explorer - Zk 6 : Internet explorer in compatibility mode Selenium Internet Explorer单击按钮 - Selenium Internet Explorer click button Selenium代码不适用于Internet Explorer - Selenium Code Not Working for Internet Explorer 如何通过 Selenium 和 Java 使用 setCapability() 忽略 Internet Explorer 的受保护模式设置? - How to ignore protected Mode Settings for Internet Explorer using setCapability() through Selenium and Java? 如何在JAVA中获取Internet Explorer的文档模式 - How to fetch the document mode of Internet Explorer in JAVA Internet Explorer未启动我的selenium webdriver代码 - Internet Explorer is not launching my selenium webdriver code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM