Merge branch 'master' of bitbucket.org:panleicim/puppeteerjs

This commit is contained in:
Lei PAN
2023-06-02 13:29:14 +02:00
2 changed files with 28 additions and 15 deletions
+18 -11
View File
@@ -110,12 +110,6 @@ class CommandorPage {
break; break;
case OCRResult.TO_REFRESH: case OCRResult.TO_REFRESH:
logWithDevice("will reload page", this.device) logWithDevice("will reload page", this.device)
// if (this.browser.isConnected()) {
// await this.page.reload();
// await this.checkIfSuccessful()
// } else {
// await delay(10000);
// if (!await this.checkIfSuccessful()) {
let cmd = "input swipe 382 682 382 1682" 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);
@@ -485,6 +479,7 @@ class CommandorPage {
} }
} catch (e) { } catch (e) {
log(e); log(e);
await this.checkResultWithOcr()
} }
} }
} }
@@ -735,7 +730,8 @@ class CommandorPage {
if (isSuccessful) { if (isSuccessful) {
checkResult = await this.ocrChecker.get_result(); checkResult = await this.ocrChecker.get_result();
} else { } else {
this.isTerminated = true await this.checkResultWithOcr()
// this.isTerminated = true
} }
// await this.checkResultWithOcr() // await this.checkResultWithOcr()
}) })
@@ -856,7 +852,10 @@ class CommandorPage {
OCRResult.GOOGLE_DISCONNECT OCRResult.GOOGLE_DISCONNECT
: :
logWithDevice("GOOGLE_DISCONNECT", this.device) logWithDevice("GOOGLE_DISCONNECT", this.device)
this.device.shell("input tap " + 411 + " " + 2100) if (this.device.model() === "MI 5s") {
this.device.shell("input tap " + 550 + " " + 1740)
} else
this.device.shell("input tap " + 411 + " " + 2100)
await delay(2000); await delay(2000);
await this.checkResultWithOcr(); await this.checkResultWithOcr();
break break
@@ -897,6 +896,8 @@ class CommandorPage {
async clickOnConfirmBtn() { async clickOnConfirmBtn() {
if (this.device.model() === "CPH2219") { if (this.device.model() === "CPH2219") {
this.device.shell("input tap " + 900 + " " + 1532) this.device.shell("input tap " + 900 + " " + 1532)
} else if (this.device.model() === "MI 5s") {
this.device.shell("input tap " + 925 + " " + 1325)
} else } else
this.device.shell("input tap " + 933 + " " + 1538) this.device.shell("input tap " + 933 + " " + 1538)
await delay(2000); await delay(2000);
@@ -939,6 +940,10 @@ class CommandorPage {
this.device.shell("input tap " + 772 + " " + 2146) this.device.shell("input tap " + 772 + " " + 2146)
await delay(2000); await delay(2000);
this.device.shell("input tap " + 772 + " " + 2146) this.device.shell("input tap " + 772 + " " + 2146)
} else if (model === "MI 5s") {
this.device.shell("input tap " + 790 + " " + 1807)
await delay(2000);
this.device.shell("input tap " + 790 + " " + 1807)
await delay(1000); await delay(1000);
} else { } else {
this.device.shell("input tap " + 800 + " " + 2215) this.device.shell("input tap " + 800 + " " + 2215)
@@ -960,17 +965,19 @@ class CommandorPage {
this.device.shell("input tap " + 550 + " " + 1920) this.device.shell("input tap " + 550 + " " + 1920)
} else if (model === "ONEPLUS A6000") { } else if (model === "ONEPLUS A6000") {
this.device.shell("input tap " + 535 + " " + 1945) this.device.shell("input tap " + 535 + " " + 1945)
} else if (model === "MI 5s") {
this.device.shell("input tap " + 510 + " " + 1615)
} else } else
this.device.shell("input tap " + 385 + " " + 2050) this.device.shell("input tap " + 385 + " " + 2050)
await delay(2000); await delay(1000);
} }
async enableDisableAirPlanMode() { async enableDisableAirPlanMode() {
logWithDevice("will enable airplane mode", this.device) logWithDevice("will enable airplane mode", this.device)
await this.device.shell("cmd connectivity airplane-mode enable") await this.device.shell("cmd connectivity airplane-mode enable")
await this.device.shell("adb shell settings put global airplane_mode_on 1") // await this.device.shell("adb shell settings put global airplane_mode_on 1")
await delay(1000) await delay(1000)
await this.device.shell("adb shell settings put global airplane_mode_on 0") // await this.device.shell("adb shell settings put global airplane_mode_on 0")
await this.device.shell("cmd connectivity airplane-mode disable") await this.device.shell("cmd connectivity airplane-mode disable")
} }
} }
+10 -4
View File
@@ -31,6 +31,7 @@ const ERR_CACHE_MISS_3 = "appuyer sur le bouton d'actualisation"
const ERR_CACHE_MISS_4 = "renvoyer les données" 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 SLIDING_CAPTCHA_FR_2 = "Glissez vers la droite pour" const SLIDING_CAPTCHA_FR_2 = "Glissez vers la droite pour"
const SLIDING_CAPTCHA_FR_3 = "la droite pour completer le puzzle"
const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour" const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
const MESSAGE_FILL_FIELD_FR_2 = "Lensemble des champs de données doivent étre complétés" const MESSAGE_FILL_FIELD_FR_2 = "Lensemble des champs de données doivent étre complétés"
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome" const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
@@ -40,6 +41,7 @@ const PAGE_OPTIMIZATION_CHROME_FR_2 = "Vous pouvez modifier vos options a tout m
const PAGE_OPTIMIZATION_CHROME_FR_3 = "Vous pouvez effectuer des modifications" const PAGE_OPTIMIZATION_CHROME_FR_3 = "Vous pouvez effectuer des modifications"
const PAGE_OPTIMIZATION_CHROME_FR_4 = "de nouvelles fonctionnalités" const PAGE_OPTIMIZATION_CHROME_FR_4 = "de nouvelles fonctionnalités"
const PAGE_OPTIMIZATION_CHROME_FR_5 = "Avec la mesure des performance" const PAGE_OPTIMIZATION_CHROME_FR_5 = "Avec la mesure des performance"
const PAGE_OPTIMIZATION_CHROME_FR_7 = "Les annonces suggérées par les"
const ONLINE_APPOINTMENT = "Online Appointment" const ONLINE_APPOINTMENT = "Online Appointment"
const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi" const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi"
const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans" const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans"
@@ -84,15 +86,21 @@ class OCRChecker {
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
} else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2)) { } else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3)) {
return OCRResult.SLIDING_CAPTCHA return OCRResult.SLIDING_CAPTCHA
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2)) { } else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2)) {
return OCRResult.FILL_FIELD return OCRResult.FILL_FIELD
} else if (result.includes(WELCOME_MESSAGE_FR)) { } else if (result.includes(WELCOME_MESSAGE_FR)) {
return OCRResult.NEED_TO_CLICK_LATE_BTN return OCRResult.NEED_TO_CLICK_LATE_BTN
} else if (result.includes(GOOGLE_DISCONNECT_FR)) {
return OCRResult.GOOGLE_DISCONNECT
} else if (result.toLowerCase().includes(ONLINE_APPOINTMENT.toLowerCase())) { } else if (result.toLowerCase().includes(ONLINE_APPOINTMENT.toLowerCase())) {
return OCRResult.ONLINE_APPOINTMENT return OCRResult.ONLINE_APPOINTMENT
} else if (result.includes(PAGE_OPTIMIZATION_CHROME_FR) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_2) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_3) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_4) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_5) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_6)) { } else if (result.includes(PAGE_OPTIMIZATION_CHROME_FR) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_2) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_3)
|| result.includes(PAGE_OPTIMIZATION_CHROME_FR_4) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_5)
|| result.includes(PAGE_OPTIMIZATION_CHROME_FR_6)
|| result.includes(PAGE_OPTIMIZATION_CHROME_FR_7)
) {
return OCRResult.PAGE_OPTIMIZATION return OCRResult.PAGE_OPTIMIZATION
} else if (result.includes(CONFIRM_RESEND_FORM_FR)) { } else if (result.includes(CONFIRM_RESEND_FORM_FR)) {
return OCRResult.CONFIRM_RESEND_FORM return OCRResult.CONFIRM_RESEND_FORM
@@ -102,8 +110,6 @@ class OCRChecker {
return OCRResult.TERMINAED return OCRResult.TERMINAED
} else if (result.includes(DIALOG_TO_SKIP)) { } else if (result.includes(DIALOG_TO_SKIP)) {
return OCRResult.TO_SKIP return OCRResult.TO_SKIP
} else if (result.includes(GOOGLE_DISCONNECT_FR)) {
return OCRResult.GOOGLE_DISCONNECT
} else if (result.includes(RECAPTCHA_FAILED_FR)) { } else if (result.includes(RECAPTCHA_FAILED_FR)) {
return OCRResult.TERMINAED return OCRResult.TERMINAED
} else { } else {