Created
September 26, 2016 06:41
-
-
Save 4M01/24bd8b3e65dafcbb30f7a74fa5fbcb3a to your computer and use it in GitHub Desktop.
Open Internet Explorer (IE) 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.ie.InternetExplorerDriver; | |
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.internetExplorer(); | |
capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true); | |
capabilities.setCapability(InternetExplorerDriver.IE_SWITCHES, "-private"); | |
System.setProperty("webdriver.ie.driver","C:\\Grid\\IEDriverServer.exe"); | |
WebDriver driver = new InternetExplorerDriver(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