CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

How To Close Only Those Chrome Windows That Has Been Open By Automation tests.

Open ninpop25 opened this issue 8 years ago • 3 comments

I Run my tests on client server (Windows machine) Via Jenkins and I want that before my Build Run it should close only those Chrome Windows that has been open by Automation tests

not able to find any method on how to do so

Provide console output if related. Use --verbose mode for more details.

# paste output here

Provide test source code if related

// paste test

Details

  • CodeceptJS version:
  • NodeJS Version:
  • Operating System:window 10
  • Protractor || WebDriverIO || Nightmare version (if related)
  • Configuration file:
# paste suite config here

ninpop25 avatar Jan 10 '18 16:01 ninpop25

@APshenkin @DavertMik : Please look into this and also please let me know that how to Run more then 1 tests with single command

ninpop25 avatar Jan 10 '18 16:01 ninpop25

Personally I have never had an issue with this, though it could be because I am using a different chrome.exe just for the tests.

You can specify the chrome.exe to use in the tests in the codeceptjs configuration file (I like to the a .js file for the config because you can do some dynamic assignments instead of having everything statically defined).

Look at the desiredCapabilities.chromeOptions.binary setting.

exports.config = {
    output: './output',
    helpers: {
        WebDriverIO: {
            url: process.env.URL || 'http://192.168.8.101',
            browser: process.env.BROWSER || 'chrome',
            restart: false,
            keepCookies: true, // Keep cookies if the browser is not restarting between tests
            desiredCapabilities: {
                unexpectedAlertBehaviour: 'ignore',
                firefox_binary: config.get('test:use_system_browser') ? '' : config.get('browser:firefox_binary'),
                chromeOptions: {
                    // Set path to the chrome binary you want to use.
                    binary: 'C:\\Users\\MillerR\\Desktop\\chrome64_57.0.2987.133\\chrome.exe',

                    // disable "chrome is being controlled by automated software"
                    args: ['disable-infobars=true'],
                },
            },
        },
        FileSystem: {},
    },
    mocha: {},
    bootstrap: false,
    teardown: null,
    hooks: [],
    tests: './tests/*_test.js',
    timeout: 10000,
    name: 'doler-js',
};

Now that you can specify the chrome.exe binary path, then you probably need an independent version of chrome. Fortunately there is a great website where you can download older versions of chrome in a standalone format here

The codeceptjs docs has information about the --grep option, but it helps if you play around with it.

reubenmiller avatar Jan 27 '18 09:01 reubenmiller

Thanks @reubenmiller

ninpop25 avatar Feb 03 '18 07:02 ninpop25