Click here to Skip to main content
15,887,336 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Updated 22-May-19 13:23pm

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.
 
Share this answer
 
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.

C#
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.ForceCreateProcessApi = true;
ieOptions.BrowserCommandLineArguments.Insert(0,"-private");
_driver = new InternetExplorerDriver($"{Directory.GetCurrentDirectory()}", ieOptions);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900