check page is closed or not before inputing user info with try catch

This commit is contained in:
2022-09-13 18:44:49 +02:00
parent 44c096aea7
commit 1ea0c04664
+23
View File
@@ -163,24 +163,47 @@ class CommandorPage {
} }
async inputPassportId(page) { async inputPassportId(page) {
try {
if (!page.isClosed()) {
await page.locator(PASSPORT_ID).focus() await page.locator(PASSPORT_ID).focus()
await delay(getRandomWaitTime()) await delay(getRandomWaitTime())
await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString()) await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString())
} }
} catch (e) {
console.log(e);
this.isTerminated = true;
}
}
async checkCGU(page) { async checkCGU(page) {
try {
if (!page.isClosed()) {
await page.locator(CGU_ID).focus() await page.locator(CGU_ID).focus()
await page.locator(CGU_ID).click() await page.locator(CGU_ID).click()
await delay(getRandomWaitTime()) await delay(getRandomWaitTime())
await page.locator(PROCESSING_ID).focus() await page.locator(PROCESSING_ID).focus()
await page.locator(PROCESSING_ID).click() await page.locator(PROCESSING_ID).click()
} }
} catch (e) {
console.log(e);
this.isTerminated = true;
}
}
async chooseStore(page) { async chooseStore(page) {
try {
if (!page.isClosed()) {
await page.locator(PREFER_STORE).focus() await page.locator(PREFER_STORE).focus()
await delay(1000) await delay(1000)
await page.click(PREFER_STORE); await page.click(PREFER_STORE);
await page.selectOption(PREFER_STORE, "faubourg"); await page.selectOption(PREFER_STORE, "faubourg");
}
} catch (e) {
console.log(e);
this.isTerminated = true;
}
// await page.click(PREFER_STORE); // await page.click(PREFER_STORE);
} }