@testwizard/commands-mobile
Version:
31 lines (24 loc) • 1 kB
JavaScript
;
const Commands = require('@testwizard/commands-core');
const Result = Commands.ResultForOkAndErrorMessage;
class SwipeCommand extends Commands.CommandBase {
constructor(testObject) {
super(testObject, 'Mobile.Swipe');
}
async execute(xStart, yStart, xEnd, yEnd, duration) {
if (xStart === undefined)
throw new Error('xStart is required');
if (yStart === undefined)
throw new Error('yStart is required');
if (xEnd === undefined)
throw new Error('xEnd is required');
if (yEnd === undefined)
throw new Error('yEnd is required');
if (duration === undefined)
throw new Error('duration is required');
const requestObj = [xStart, yStart, xEnd, yEnd, duration];
const json = await this.executeCommand(requestObj);
return new Result(json, 'swipe was successful', 'swipe failed');
}
}
module.exports = SwipeCommand;