我需要在Winodws10上以私有(private)模式打开IE11。尝试使用以下代码,但抛出异常“启动 Internet Explorer 时出现意外错误。无法使用 CreateProcess() API。要在 Internet Explorer 8 或更高版本中使用 CreateProcess(),HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer 中注册表设置的值\Main\TabProcGrowth 必须为“0”。”
代码: int val = Convert.ToInt32(Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth", "", -1));
InternetExplorerOptions ops = new InternetExplorerOptions();
ops.ForceCreateProcessApi = true;
ops.BrowserCommandLineArguments = "-private";
IWebDriver driver = new InternetExplorerDriver(url, ops);
RegEdit中有 key ,我可以成功读取。
最佳答案
删除 ops.ForceCreateProcessApi = true;
有助于启动浏览器,但不能在私有(private)模式下启动。您需要组合
ops.ForceCreateProcessApi = true;
ops.BrowserCommandLineArguments = "-private";
关于Selenium C# InPrivate 模式 Internet Explorer IE 11 抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42728388/