Last active
September 26, 2016 06:33
-
-
Save 4M01/2df8c18249a8015edf698e7dacd5bf55 to your computer and use it in GitHub Desktop.
Open Chrome Browser in Incognito Mode using Selenium WebDriver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.openqa.selenium.chrome.ChromeOptions; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
/** | |
* Created by Amol Chavan on 9/19/2016. | |
*/ | |
public class PrivateBrowsing { | |
public static void main(String args[]){ | |
createInstance(); | |
} | |
public static WebDriver createInstance(){ | |
DesiredCapabilities capabilities = DesiredCapabilities.chrome(); | |
ChromeOptions options = new ChromeOptions(); | |
options.addArguments("--incognito"); | |
capabilities.setCapability(ChromeOptions.CAPABILITY, options); | |
System.setProperty("webdriver.chrome.driver","C:\\Grid\\chromedriver.exe"); | |
WebDriver driver = new ChromeDriver(capabilities); | |
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