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

This commit is contained in:
2022-09-12 13:47:58 +02:00
parent 2076154da7
commit 1993480fa6
+16
View File
@@ -101,14 +101,23 @@ class CommandorPage {
}
async chooseCountry(page) {
if (!page.isClosed()) {
try {
await page.locator(COUNTRY_ID).focus();
await delay(getRandomWaitTime())
await page.click(COUNTRY_ID);
await delay(getRandomWaitTime())
await page.selectOption(COUNTRY_ID, 'FR');
await delay(getRandomWaitTime())
} catch (e) {
console.log(e);
this.isTerminated = true;
}
// await page.click(COUNTRY_ID);
}
}
async fillEmail(page) {
await page.locator(EMAIL_ID).focus();
@@ -124,12 +133,19 @@ class CommandorPage {
async inputName(page) {
await page.locator(LAST_NAME).focus()
await delay(getRandomWaitTime())
try {
if (!page.isClosed()) {
await page.locator(LAST_NAME).fill(this.contact.lastName)
await page.locator(FIRST_NAME).focus()
await delay(getRandomWaitTime())
await page.locator(FIRST_NAME).fill(this.contact.firstName)
}
} catch (e) {
console.log(e);
this.isTerminated = true
}
}
async inputPassportId(page) {