support chrome

This commit is contained in:
2024-09-21 19:00:47 +02:00
parent ff9c9bc07d
commit 87910a6524
2 changed files with 25 additions and 35 deletions
+21 -34
View File
@@ -397,7 +397,7 @@ class CommandorPage {
logWithDevice("input name called with this.isNameInput=" + this.isNameInput, this.device)
if (this.browser.isConnected() && !this.isTerminated && !this.page.isClosed()) {
if (!this.isNameInput) {
await page.focus(LAST_NAME);
// await page.focus(LAST_NAME);
await delay(getRandomWaitTime());
console.log("will clear surname field");
await page.evaluate(() => {
@@ -886,10 +886,11 @@ class CommandorPage {
checkResult = await this.ocrChecker.get_result();
// await this.checkResultWithOcr()
} else {
if (checkResult === OCRResult.SLIDING_CAPTCHA) {
checkResult = OCRResult.TERMINAED
this.isTerminated = true
}
await this.checkResultWithOcr()
// if (checkResult === OCRResult.SLIDING_CAPTCHA) {
// checkResult = OCRResult.TERMINAED
// this.isTerminated = true
// }
}
})
await delay(10 * 1000)
@@ -922,6 +923,7 @@ class CommandorPage {
// add listeners
let pages = await timeout(this.browser.pages(), 5 * 1000);
pages.forEach((currentPage) => {
logWithDevice("current url is " + currentPage.url(), this.device)
if (currentPage.url() === RDV_URL) {
this.page = currentPage;
} else {
@@ -943,35 +945,6 @@ class CommandorPage {
await this.resetBrowser()
// this.isTerminated = true;
}
// try {
// for (const currentPage of pages) {
// if (currentPage.url() === RDV_URL) {
// 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 {
// await currentPage.close()
// } catch (e) {
// console.log(e)
// }
// }
// }
// } catch (e) {
// this.isTerminated = true;
// console.log(e)
// }
} catch (e) {
console.log(e)
this.isTerminated = true
@@ -982,6 +955,19 @@ class CommandorPage {
if (this.browser.isConnected()) {
logWithDevice("will use old page", this.device)
logWithDevice("this.page.bringToFront();", this.device)
let pages = await timeout(this.browser.pages(), 5 * 1000);
pages.forEach((currentPage) => {
if (currentPage.url() === RDV_URL) {
this.page = currentPage;
} else {
try {
if (!this.isTerminated)
currentPage.close()
} catch (e) {
console.log(e)
}
}
})
await this.page.bringToFront();
// this.page = pages;
// this.page.await
@@ -1092,6 +1078,7 @@ class CommandorPage {
else
await this.device.shell("input tap " + 488 + " " + 1848)
await delay(2000);
await this.checkResultWithOcr();
break;
case
OCRResult.TO_REFRESH
+4 -1
View File
@@ -49,6 +49,7 @@ const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
const MESSAGE_FILL_FIELD_FR_5 = "email vous sera envoyé pour vous"
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
const WELCOME_MESSAGE_FR_2 = "Chrome Connectez-vous"
const PAGE_OPTIMIZATION_CHROME_FR = "Vous pouvez changer d'avis a tout moment dans"
const PAGE_OPTIMIZATION_CHROME_FR_6 = "Vous pouvez changer davis a tout moment"
const PAGE_OPTIMIZATION_CHROME_FR_2 = "Vous pouvez modifier vos options a tout moment"
@@ -149,7 +150,9 @@ class OCRChecker {
// if (result.includes("rac"))
// return OCRResult.SLIDING_CAPTCHA_REFRESH
return OCRResult.SLIDING_CAPTCHA
} else if (result.includes(WELCOME_MESSAGE_FR)) {
} else if (result.includes(WELCOME_MESSAGE_FR)
|| result.includes(WELCOME_MESSAGE_FR_2)
) {
await this.deleteFile(fileName)
return OCRResult.NEED_TO_CLICK_LATE_BTN
} else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) {