Skip to content

Instantly share code, notes, and snippets.

@4M01
Last active October 16, 2019 12:31
Show Gist options
  • Save 4M01/9b60a5f852fabdc5f65c9496e6eccf03 to your computer and use it in GitHub Desktop.
Save 4M01/9b60a5f852fabdc5f65c9496e6eccf03 to your computer and use it in GitHub Desktop.
Open Firefox Browser in Incognito Mode using Selenium WebDriver
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
/**
* Created by Amol Chavan on 9/19/2016.
*/
public class PrivateBrowsing {
public static void main(String args[]){
createInstance();
}
public static WebDriver createInstance(){
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.private.browsing.autostart",true);
WebDriver driver = new FirefoxDriver(firefoxProfile);
driver.get("http://www.google.com");
return driver;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment