Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99044

How to use WebDriverRunner to create a Chrome browser in incognito mode

$
0
0

I'm looking for an option to open chrome in INCOGNITO for my automation tests using SelenIDE/JUNIT/Maven.

I'm not really sure what kind of information I need to give here. I'll add a copy of our LocalTest page, which steers the WebdriverRunner.

I call the actual Url in the test class itself, because the site has different starting points to be tested.

this is how i'm callling the Url:

@Beforepublic void OpenCarUrl(){WebDriverRunner.getWebDriver().get("MyUrl");}

I hope this is plenty but if I need to provide more information I'm always on the ready to answer.

the copy of our LocalTest

public class LocalTest extends SelenideHelperClass {private static Logger logger = LoggerFactory.getLogger(LocalTest.class);private static boolean osIs(String os) {    return System.getProperty("os.name").toLowerCase().contains(os);}@BeforeClasspublic static void setupDriver() {    if (System.getProperty("CHROMEDRIVER_HOME") != null) {        System.setProperty("webdriver.chrome.driver", System.getProperty("CHROMEDRIVER_HOME") +"/chromedriver");    } else if (System.getenv("CHROMEDRIVER_HOME") != null) {        System.setProperty("webdriver.chrome.driver", System.getenv("CHROMEDRIVER_HOME") +"/chromedriver");    } else {        String driver;        if (osIs("mac")) {            driver = "chromedriver-mac";        } else if (osIs("windows")) {            driver = "chromedriver.exe";        } else if (osIs("linux")) {            driver = "chromedriver-linux";        } else {            throw new RuntimeException("OS could not be determined, chromedriver cannot be set or is unavailable");        }        System.setProperty("webdriver.chrome.driver", System.getProperty("java.io.tmpdir") +"/chromedriver/"+ driver);    }    System.setProperty("selenide.browser", "Chrome");    logger.info("Set selenide.browser to Chrome");    logger.info("Set webdriver.chrome.driver to "+ System.getProperty("webdriver.chrome.driver"));    // ----------------}@AfterClasspublic static void closeDriver() {WebDriverRunner.getWebDriver().quit();}}

Viewing all articles
Browse latest Browse all 99044

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>