fix(page): fix missing awaits in mouse.click (#4541)

Lack of await causes dangling promises, which lead to unhandled rejections that cannot be caught if these calls fail (e.g. if the page is closed). 

References #4536
This commit is contained in:
Philip Bergqvist 2019-06-10 04:42:19 -04:00 committed by Andrey Lushnikov
parent 7faf1c9030
commit dd6fcfe77b

View File

@ -224,11 +224,20 @@ class Mouse {
*/
async click(x, y, options = {}) {
const {delay = null} = options;
this.move(x, y);
this.down(options);
if (delay !== null)
if (delay !== null) {
await Promise.all([
this.move(x, y),
this.down(options),
]);
await new Promise(f => setTimeout(f, delay));
await this.up(options);
await this.up(options);
} else {
await Promise.all([
this.move(x, y),
this.down(options),
this.up(options),
]);
}
}
/**