handle ssl error
This commit is contained in:
@@ -178,7 +178,8 @@ class CommandorPage {
|
||||
if (this.isTerminated) {
|
||||
log(this.device.model() + ":request terminated, send cancel()");
|
||||
try {
|
||||
await this.page.close()
|
||||
if (this.page !== undefined)
|
||||
await this.page.close()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
@@ -726,16 +727,6 @@ class CommandorPage {
|
||||
await this.checkResultWithOcr();
|
||||
if (this.page.url() === BLANK_URL) {
|
||||
this.isTerminated = true;
|
||||
} else {
|
||||
try {
|
||||
// let errorItem = this.page.locator("div.alert");
|
||||
// if (errorItem) {
|
||||
// let errorContent = await errorItem.innerHTML();
|
||||
// await this.handleError(errorContent);
|
||||
// }
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,6 +815,12 @@ class CommandorPage {
|
||||
await delay(10 * 1000)
|
||||
}
|
||||
switch (checkResult) {
|
||||
case OCRResult.SLIDING_CAPTCHA_LOADING:
|
||||
this.isTerminated = true;
|
||||
break;
|
||||
case OCRResult.SSL_CERT_ERROR:
|
||||
await this.resetBrowser()
|
||||
break;
|
||||
case OCRResult.TERMINAED:
|
||||
this.isTerminated = true;
|
||||
break;
|
||||
@@ -842,17 +839,29 @@ class CommandorPage {
|
||||
logWithDevice("get pages", this.device)
|
||||
let pages = await this.browser.pages();
|
||||
try {
|
||||
pages.forEach((currentPage) => {
|
||||
for (const currentPage of pages) {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
this.page = currentPage;
|
||||
logWithDevice("get content", this.device)
|
||||
let pageContent = await currentPage.content()
|
||||
logWithDevice("content:" + pageContent, this.device)
|
||||
if (!pageContent.includes("geo.captcha-delivery.com")) {
|
||||
this.page = currentPage;
|
||||
break
|
||||
} else {
|
||||
try {
|
||||
await currentPage.close()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
currentPage.close()
|
||||
await currentPage.close()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
this.isTerminated = true;
|
||||
console.log(e)
|
||||
|
||||
Reference in New Issue
Block a user