From 44c096aea7b2bc4e7096691c1a39fffdf5a611b1 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Tue, 13 Sep 2022 13:49:40 +0200 Subject: [PATCH] check page is closed or not before inputing user info with try catch --- src/workers/CommandorPage.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index cac8ade..ea4d228 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -120,9 +120,15 @@ class CommandorPage { } async fillEmail(page) { - await page.locator(EMAIL_ID).focus(); - await delay(getRandomWaitTime()) - await page.locator(EMAIL_ID).fill(this.contact.mail); + try { + if (!page.isClosed()) { + await page.locator(EMAIL_ID).focus(); + await delay(getRandomWaitTime()) + await page.locator(EMAIL_ID).fill(this.contact.mail); + } + } catch (e) { + console.log(e) + } } async inputPhoneNumber(page) {