check page is closed or not before inputing user info with try catch
This commit is contained in:
@@ -101,13 +101,22 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async chooseCountry(page) {
|
async chooseCountry(page) {
|
||||||
await page.locator(COUNTRY_ID).focus();
|
if (!page.isClosed()) {
|
||||||
await delay(getRandomWaitTime())
|
try {
|
||||||
await page.click(COUNTRY_ID);
|
|
||||||
await delay(getRandomWaitTime())
|
|
||||||
await page.selectOption(COUNTRY_ID, 'FR');
|
await page.locator(COUNTRY_ID).focus();
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
// await page.click(COUNTRY_ID);
|
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) {
|
async fillEmail(page) {
|
||||||
@@ -124,11 +133,18 @@ class CommandorPage {
|
|||||||
async inputName(page) {
|
async inputName(page) {
|
||||||
await page.locator(LAST_NAME).focus()
|
await page.locator(LAST_NAME).focus()
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
if (!page.isClosed()) {
|
try {
|
||||||
await page.locator(LAST_NAME).fill(this.contact.lastName)
|
|
||||||
await page.locator(FIRST_NAME).focus()
|
|
||||||
await delay(getRandomWaitTime())
|
if (!page.isClosed()) {
|
||||||
await page.locator(FIRST_NAME).fill(this.contact.firstName)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user