Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to close the browser when the test case gets failed. #418

Open
akshaygupta5233 opened this issue Nov 2, 2018 · 0 comments
Open

How to close the browser when the test case gets failed. #418

akshaygupta5233 opened this issue Nov 2, 2018 · 0 comments

Comments

@akshaygupta5233
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant