nightwatch-cucumber
nightwatch-cucumber copied to clipboard
How to close the browser when the test case gets failed.
Hi All When I run my feature file, suppose it is having 10 test cases and in between if one gets failed, then the browser does not get closed on its own. Need to know how to close the browser on failure of test case, as the next test case runs over it and hence gets failed.
This is the nightwatch.conf.js which i am using------> Kindly help me over this. Thanks
const seleniumServer = require('selenium-server'); const chromedriver = require('chromedriver'); const geckodriver = require('geckodriver'); var reporter = require('cucumber-html-reporter');
require('nightwatch-cucumber')({
// nightwatchOutput: false,
cucumberArgs: ['--require', 'step-definitions', '--require', 'step-definitions/hooks.js', '--format', 'node_modules/cucumber-pretty', '--format', 'json:reports/cucumber.json', 'features' ]
});
module.exports = { "test_workers": { "enabled": true, "workers": "auto" },
output_folder: 'reports', custom_assertions_path: '', live_output: false, disable_colors: false, selenium: { start_process: true, server_path: seleniumServer.path, log_path: '', host: '127.0.0.1', port: 4444 }, test_settings: { default: { launch_url: 'http://localhost:8087', selenium_port: 4444, selenium_host: '127.0.0.1', screenshots: { enabled: true, on_failure: true, path: 'reports/screenshots' }, desiredCapabilities: { browserName: 'chrome', javascriptEnabled: true, acceptSslCerts: true, chromeOptions: { // args: ['incognito', 'headless', 'no-sandbox', 'disable-gpu'] } }, end_session_on_fail: true, "skip_testcases_on_fail": false, detailed_output: true, },
chrome: {
screenshots: {
enabled: true,
on_failure: true,
path: 'reports/screenshots'
},
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
// args: ['incognito', 'headless', 'no-sandbox', 'disable-gpu']
}
},
selenium: {
cli_args: {
'webdriver.chrome.driver': chromedriver.path
}
}
},
firefox: {
screenshots: {
enabled: true,
on_failure: true,
path: 'reports/screenshots'
},
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
marionette: true,
firefoxOptions: {
// args: ['incognito', 'headless', 'no-sandbox', 'disable-gpu']
}
},
selenium: {
cli_args: {
'webdriver.gecko.driver': geckodriver.path
}
}
},
} };
var options = { theme: 'bootstrap', jsonFile: 'reports/cucumber.json', output: 'reports/cucumber_reports.html', // output: 'reports/output_JUnit.xml', reportSuiteAsScenarios: true, launchReport: true, metadata: { "App Version": "0.3.2", "Test Environment": "Demo", "Browser": "Chrome 54.0.2840.98", "Platform": "Windows 7", "Parallel": "Scenarios", "Executed": "Local" } };
reporter.generate(options);