john-doherty / selenium-cucumber-js

Browser automation framework written in pure JavaScript using official selenium-webdriver and cucumber-js
ISC License
120 stars 89 forks source link

Possibility to open browser in incognito mode #76

Closed Sjain01 closed 6 years ago

Sjain01 commented 6 years ago

I want to run my test in incognito mode, is it possible using this library.

john-doherty commented 6 years ago

Yes, you can add the Chrome incognito command line switch to line 17 of chromeDriver.js, so it looks like this:

'use strict';

var chromedriver = require('chromedriver');
var selenium = require('selenium-webdriver');

/**
 * Creates a Selenium WebDriver using Chrome as the browser
 * @returns {ThenableWebDriver} selenium web driver
 */
module.exports = function() {

    var driver = new selenium.Builder().withCapabilities({
        browserName: 'chrome',
        javascriptEnabled: true,
        acceptSslCerts: true,
        chromeOptions: {
            args: ['start-maximized', 'disable-extensions', 'incognito']
        },
        path: chromedriver.path
    }).build();

    driver.manage().window().maximize();

    return driver;
};
Sjain01 commented 6 years ago

@john-doherty - Thank you for your response, I used it but the browser still opens up in normal mode and not incognito. could you please advise.