I've been searching a lot and found lots of answers but none of them working. I want to start a Firefox Webdriver in private mode.
I have Firefox version 54 installed and gecko driver v0.18. Selenium v3.4.0
I use the following code:
FirefoxProfile profile = new FirefoxProfile();
profile.EnableNativeEvents = true;
profile.AcceptUntrustedCertificates = true;
profile.AssumeUntrustedCertificateIssuer = true;
profile.SetPreference("browser.privatebrowsing.autostart", true);
profile.SetPreference("browser.privatebrowsing.dont_prompt_on_enter", true);
//profile.SetPreference("browser.startup.homepage", ConfigurationManager.AppSettings["StartURL"]);
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
//options.AddArgument("--private");
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(DRIVER_PATH);
webDriver = new FirefoxDriver(service, options, TimeSpan.FromMilliseconds(15000));
var screenWidth = Screen.PrimaryScreen.Bounds.Width;
var screenHeight = Screen.PrimaryScreen.Bounds.Height;
webDriver.Manage().Window.Size = new System.Drawing.Size(screenWidth, screenHeight);
webDriver.Navigate().GoToUrl(ConfigurationManager.AppSettings["StartURL"]);
//from firefox 55 can maximize again. Wait for update.
//webDriver.Manage().Window.Maximize();
I also noticed that when I debug during a test and press CTRL+SHIFT+P a new "private" window opens but I do NOT see the private glasses icon. What is wrong? Is this a bug?