Merge branch 'feature/disconnect_after_opening_appointment_url' of bitbucket.org:panleicim/puppeteerjs into feature/disconnect_after_opening_appointment_url

This commit is contained in:
2023-05-29 13:53:21 +02:00
2 changed files with 24 additions and 13 deletions
+9 -1
View File
@@ -116,7 +116,7 @@ class CommandorPage {
// } else { // } else {
// await delay(10000); // await delay(10000);
// if (!await this.checkIfSuccessful()) { // if (!await this.checkIfSuccessful()) {
let cmd = "input swipe 382 482 382 1582" let cmd = "input swipe 382 682 382 1682"
logWithDevice("will send cmd:" + cmd, this.device) logWithDevice("will send cmd:" + cmd, this.device)
this.device.shell(cmd); this.device.shell(cmd);
await delay(3000); await delay(3000);
@@ -769,17 +769,25 @@ class CommandorPage {
} else { } else {
logWithDevice("this.browser.isConnected() is " + this.browser.isConnected(), this.device) logWithDevice("this.browser.isConnected() is " + this.browser.isConnected(), this.device)
if (this.browser.isConnected()) { if (this.browser.isConnected()) {
try {
let pages = await this.browser.pages(); let pages = await this.browser.pages();
logWithDevice("get pages", this.device)
pages.forEach((currentPage) => { pages.forEach((currentPage) => {
if (currentPage.url() === RDV_URL) { if (currentPage.url() === RDV_URL) {
this.page = currentPage; this.page = currentPage;
} }
}) })
logWithDevice("this.page.bringToFront();", this.device)
await this.page.bringToFront(); await this.page.bringToFront();
// this.page = pages; // this.page = pages;
// this.page.await // this.page.await
await this.fillFields(this.page) await this.fillFields(this.page)
await delay(2 * 1000); await delay(2 * 1000);
} catch (e) {
console.log(e)
this.isTerminated = true
}
} }
} }
// if (!this.browser.isConnected()) { // if (!this.browser.isConnected()) {
+4 -1
View File
@@ -26,6 +26,9 @@ const BLOCKED_MSG_EN = "have been blocked"
const BLOCKED_MSG_FR = "avez été bloqué" const BLOCKED_MSG_FR = "avez été bloqué"
const CHECKING_MSG_FR = "Verifying" const CHECKING_MSG_FR = "Verifying"
const ERR_CACHE_MISS = "ERR_CACHE_MISS" const ERR_CACHE_MISS = "ERR_CACHE_MISS"
const ERR_CACHE_MISS_2 = "ERR_CACHE-MISS"
const ERR_CACHE_MISS_3 = "appuyer sur le bouton d'actualisation"
const ERR_CACHE_MISS_4 = "renvoyer les données"
const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification" const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification"
const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour" const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome" const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
@@ -74,7 +77,7 @@ class OCRChecker {
return OCRResult.RECAPTCHA_ERROR return OCRResult.RECAPTCHA_ERROR
} else if (result.includes(BLOCKED_MSG_EN) || result.includes(BLOCKED_MSG_FR)) { } else if (result.includes(BLOCKED_MSG_EN) || result.includes(BLOCKED_MSG_FR)) {
return OCRResult.BLOCKED return OCRResult.BLOCKED
} else if (result.includes(ERR_CACHE_MISS)) { } else if (result.includes(ERR_CACHE_MISS) || result.includes(ERR_CACHE_MISS_2) || result.includes(ERR_CACHE_MISS_3) || result.includes(ERR_CACHE_MISS_4)) {
return OCRResult.TO_REFRESH return OCRResult.TO_REFRESH
} else if (result.includes(CHECKING_MSG_FR)) { } else if (result.includes(CHECKING_MSG_FR)) {
return OCRResult.RECHECK return OCRResult.RECHECK