I tried to add the following function as a helper at the beginning
exports.EditTime = function (number) {
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.number);
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.ENTER);
}
But it seems doesn't work if I assigned number as NUMPAD1, NUMPAD2 ..... Therefore, I changed the function into a switch case function which looks stupid...
exports.EditTime = function (number) {
switch (number) {
case 1:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD1);
case 2:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD2);
case 3:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD3);
case 4:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD4);
case 5:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD5);
case 6:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD6);
case 7:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD7);
case 8:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD8);
case 9:
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.NUMPAD9);
}
element(by.className('numberFormat p-inputtext p-component')).sendKeys(protractor.Key.ENTER);
sleep(1000);
}
I am wondering if anyone has a better approach to implement such a function?
Aucun commentaire:
Enregistrer un commentaire