I am new to browser stack and trying to execute edge in private mode on browser stack. I am trying to do it with following code but it's launching in normal mode whatsoever.
caps.setCapability("os_version", osVersion);
caps.setCapability("os", os);
caps.setCapability("resolution", "1920x1080");
caps.setCapability("browser", browser);
caps.setCapability("browser_version", browserVersion);
if(isPrivate && browser.equalsIgnoreCase("chrome")) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("incognito");
caps.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
}
else if(isPrivate && browser.equalsIgnoreCase("edge")) {
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setCapability("InPrivate",true);
caps.merge(DesiredCapabilities.edge().merge(edgeOptions));
}
I am using the following versions in pom and unfortunately can't upgrade at the moment:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
For anyone looking for a solution. I manage to achieve this by adding
<dependency>
<groupId>com.microsoft.edge</groupId>
<artifactId>msedge-selenium-tools-java</artifactId>
<version>3.141.1</version>
</dependency>
And then
import com.microsoft.edge.seleniumtools.EdgeOptions;
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("inprivate");
CodePudding user response:
I suggest installing the Selenium Tools for Microsoft Edge since you're using Selenium 3.141.59. You can follow the instruction here: https://github.com/microsoft/edge-selenium-tools#java
To enable inprivate mode, you can try the following sample code:
edgeOptions.addArguments("-inprivate")