无法在C#中使用selenium Web驱动程序在私有模式下启动IE
问题描述:
无法使用Selenium Web驱动程序在私人模式下启动IE#
使用所需功能在私人模式下打开IEdriverserver尝试使用SetCapabilties
也使用了internetserverOptions但找不到分辨率
我有什么试过:
Unable to Launch IE in Private Mode using Selenium Web driver in c#
Tried with SetCapabilties using desired capabilities to open the IEdriverserver in Private mode
Also used internetserverOptions but could not find the resolution
What I have tried:
Unable to Launch IE in Private Mode using Selenium Web driver in c#
Tried with SetCapabilties using desired capabilities to open the IEdriverserver in Private mode
Also used internetserverOptions but could not find the resolution
答
这个的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);
$ b $bсapabilities.setCapability(InternetExplorerDriver.IE_SWITCHES, - private);
InternetExplorerDriver driver = new InternetExplorerDriver(capabilities);
希望它有所帮助。
Java code for this should look like this
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);
Hope it helps.
我使用ForceCreateProcessApi设置,设置为true,并在浏览器命令行参数中添加-private选项。 br />
我还必须更改注册表项:HKEY_CURRENT_USER \Software \ Mysoftoft \Internet Explorer \ Main \TabProcGrowth
TabProcGrowth是Internet Explorer下的值主要,不是关键。我在Internet Explorer \ Main下为TabProcGrowth创建了一个DWord值,并将值设置为0.
FYI,ForceCreateProcessApi被视为不受支持的方法。 />
I got this to work using the ForceCreateProcessApi setting, set to true, and adding the "-private" option to the browser command line arguments.
I also had to change the registry key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth
TabProcGrowth is a value under Internet Explorer\Main, not a key. I created a DWord value for TabProcGrowth under Internet Explorer\Main, and set the value to 0.
FYI, the ForceCreateProcessApi is viewed as an unsupported approach.
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.ForceCreateProcessApi = true;
ieOptions.BrowserCommandLineArguments.Insert(0,"-private");
_driver = new InternetExplorerDriver(
{Directory.GetCurrentDirectory()},ieOptions);
"{Directory.GetCurrentDirectory()}", ieOptions);