nightwatch
Version:
Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.
42 lines (34 loc) • 889 B
JavaScript
const ClientCommand = require('./_base-command.js');
/**
* Resizes the current window.
*
* @example
* this.demoTest = function (browser) {
* browser.resizeWindow(1000, 800);
* };
*
*
* @method resizeWindow
* @param {number} width The new window width.
* @param {number} height The new window height.
* @param {function} [callback] Optional callback function to be called when the command finishes.
* @see windowSize
* @api protocol.contexts
*/
class ResizeWindow extends ClientCommand {
performAction(callback) {
const {width, height} = this;
this.transportActions.setWindowSize({
width,
height
}).catch(err => {
return err;
}).then(result => callback(result));
}
command(width, height, callback) {
this.width = width;
this.height = height;
return super.command(callback);
}
}
module.exports = ResizeWindow;