diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index ea4d228..f2bdc7e 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -163,24 +163,47 @@ class CommandorPage { } async inputPassportId(page) { - await page.locator(PASSPORT_ID).focus() - await delay(getRandomWaitTime()) - await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString()) + try { + if (!page.isClosed()) { + + await page.locator(PASSPORT_ID).focus() + await delay(getRandomWaitTime()) + await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString()) + } + } catch (e) { + console.log(e); + this.isTerminated = true; + } + } async checkCGU(page) { - await page.locator(CGU_ID).focus() - await page.locator(CGU_ID).click() - await delay(getRandomWaitTime()) - await page.locator(PROCESSING_ID).focus() - await page.locator(PROCESSING_ID).click() + try { + if (!page.isClosed()) { + await page.locator(CGU_ID).focus() + await page.locator(CGU_ID).click() + await delay(getRandomWaitTime()) + await page.locator(PROCESSING_ID).focus() + await page.locator(PROCESSING_ID).click() + } + } catch (e) { + console.log(e); + this.isTerminated = true; + } } async chooseStore(page) { - await page.locator(PREFER_STORE).focus() - await delay(1000) - await page.click(PREFER_STORE); - await page.selectOption(PREFER_STORE, "faubourg"); + try { + if (!page.isClosed()) { + await page.locator(PREFER_STORE).focus() + await delay(1000) + await page.click(PREFER_STORE); + await page.selectOption(PREFER_STORE, "faubourg"); + } + } catch (e) { + console.log(e); + this.isTerminated = true; + } // await page.click(PREFER_STORE); }