UNPKG

nightwatch

Version:

Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.

44 lines (41 loc) 1.35 kB
const ProtocolAction = require('./_base-action.js'); /** * Opens a new top-level browser window, which can be either a tab (default) or a separate new window. * * This command is only available for W3C Webdriver compatible browsers. * * @example * module.exports = { * 'demo Test': function(browser) { * // open a new window tab (default) * browser.openNewWindow(function(result) { * console.log(result); * }); * * // open a new window * browser.openNewWindow('window', function(result) { * console.log(result); * }); * }, * * 'ES6 async demo Test': async function(browser) { * const result = await browser.openNewWindow(); * console.log('result value is:', result.value); * } * } * * @link /#dfn-new-window * @param {string} [type] Can be either "tab" or "window", with "tab" set to default if none is specified. * @param {function} [callback] Optional callback function to be called when the command finishes. * @api protocol.contexts * @deprecated In favour of `.window.open()`. */ module.exports = class Session extends ProtocolAction { command(type = 'tab', callback) { if (typeof type == 'function' && callback === undefined) { callback = arguments[0]; type = 'tab'; } return this.transportActions.openNewWindow(type, callback); } };