Aaron Greenwald
xit('should not allow sending an empty message',
test.specAsync(async () => {
//check that the value is not sent if the message is empty
await driver.safeClick('sendButton');
await test.expectElementToNotExist('activity-guid');
await test.expectElementToNotExist('activity-1001');
//now type something, delete it and try to send
//again to check that it is not sent either
await driver.typeOnKeyboard('a');
await driver.tapKeyboardDelete(1);
await driver.sleep(500);
await driver.safeClick('sendButton', 1000);
await test.expectElementToNotExist('activity-guid');
await test.expectElementToNotExist('activity-1001');
}));
wd.addPromiseChainMethod('typeOnKeyboard', function (val) {
let t = this.execute(
'target.frontMostApp().keyboard()'
).sleep(750);
for (let i = 0; i < val.length; i++) {
t = t.sleep(150).execute(
`target
.frontMostApp()
.keyboard()
.typeString('${val[i]}')`
);
}
return t;
});
...
expectElementToNotExist: async testId => {
let element;
for (let i = 0; i < 20; i++) {
element = await driver.getElementIfExists(testId, 50);
if (element) {
// if it's still there check back in a little bit
await driver.sleep(50);
} else {
element = undefined;
break;
}
}
expect({element, testId}).not.toBeAValidElement();
},
...
Clueless
Beginner
Cynic
Expert
Stability
Lots of Options
Few Excuses