Convert Scripts to ES5 format
Library usage
v1 Library usage
setup.wd.addPromiseChainMethod('touch', setup.actions.touch);
var MYFUNCTION = {
Button: "Submit",
Search: "Lets Search",
MySubFunction: () => {
return driver
.waitForElementById(MYFUNCTION.Button, 8000)
.click()
.sleep(3000)
.elementByIdIfExists(MYFUNCTION.Search)
.sendKeys("bek")
.then(saveScreen)
.then(clickToTab)
},
};
function clickToTab() {
return driver
.getWindowSize()
.then((size) => {
return driver.sleep(1000)
.touch({ x: size.width * 4 / 5, y: size.height * 2 / 13 })
})
};
v2 Library usage
const path = require('path');
let Momentum = require(path.join(__dirname, '../local/Momentum'));
[Momentum.Library(Id=xxxxxxxx)]
//..::PLEASE DO NOT MODIFY THE FIRST 3 LINES::..
const {wd} = require('../setup/v2setup');
const actions = require('../setup/actions');
exports.setDriverMethods = (driver) => {
wd.addPromiseChainMethod('touch', actions.touch);
}
//..
//..Your Code and Functions
//..
//bottom of the page
exports.MYFUNCTION = MYFUNCTION;
exports.clickToTab = clickToTab;
Call Functions in Step
Define Library (Only v2)
const {setDriverMethods, MYFUNCTION} = require('../Libraries/mylibrary');
Add this line at the end of the BEFORE Method of the TestCase. (Only v2)
v1 Case Usage
v2 Case Usage