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) {
|
||||
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())
|
||||
// await page.click(COUNTRY_ID);
|
||||
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) {
|
||||
@@ -124,11 +133,18 @@ class CommandorPage {
|
||||
async inputName(page) {
|
||||
await page.locator(LAST_NAME).focus()
|
||||
await delay(getRandomWaitTime())
|
||||
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)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user