UNPKG

nightwatch

Version:

Easy to use Node.js based End-to-End testing solution for browser based apps and websites, using the W3C WebDriver API.

41 lines (34 loc) 966 B
/** * Sample automated test scenario for Nightwatch.js * * > it navigates to page that has onbeforeunload handler */ module.exports = { disabled: true, 'go to page with unload handler': function(client) { client .url('http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm') .waitForElementVisible('body', 1000); }, 'navigate away from page WITH unload handler': function(client) { var hasDialog = false; client .hasOnBeforeUnload(function(result) { this.verify.equal(result, true, 'The page should have an onbeforeunload handler'); hasDialog = result; }) .url('http://google.com', function() { if (hasDialog) { this.acceptAlert(); } }) .waitForElementVisible('body', 1000); }, 'go to nightwatch' : function(c) { c.url('http://nightwatchjs.org') .waitForElementVisible('body', 1000); }, after : function(c) { c.end(); } };