use brave as browser

This commit is contained in:
2023-07-18 12:44:32 +02:00
parent 48ff394117
commit ba7018aa57
3 changed files with 78 additions and 20 deletions
+56 -19
View File
@@ -107,6 +107,10 @@ class CommandorPage {
// get url and push to server
await this.push_message_to_queue(PublishType.SUCCESS)
break;
case OCRResult.RECAPTCHA_ERROR:
// get url and push to server
await this.fillFields()
break;
case OCRResult.TO_REFRESH:
logWithDevice("will reload page", this.device)
let cmd = "input swipe 382 682 382 1682"
@@ -115,8 +119,6 @@ class CommandorPage {
await delay(3000);
await this.clickOnConfirmBtn();
await this.checkResultWithOcr();
// }
// }
break;
}
}
@@ -486,14 +488,12 @@ class CommandorPage {
}
async fillFields(page, airePlanMode) {
async fillFields(page) {
logWithDevice("fillFields called for contact: " + this.contact.mail, this.device)
logWithDevice("this.isFillingFields: " + this.isFillingFields, this.device);
logWithDevice("this.isTerminated: " + this.isTerminated, this.device);
if (!this.isFillingFields && !this.isTerminated) {
this.isFillingFields = true;
if (airePlanMode) {
// await this.enableDisableAirPlanMode();
}
await this.chooseStore(page);
await this.inputName(page);
await this.chooseCountry(page);
@@ -640,9 +640,7 @@ class CommandorPage {
await this.page.reload()
} else {
if (this.page.url() === RDV_URL) {
await this.fillFields(this.page, true);
// if (this.isFillingFields)
// await this.getErrors()
await this.fillFields(this.page);
} else {
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
log("successful");
@@ -882,18 +880,37 @@ class CommandorPage {
}
break;
case
OCRResult.RECAPTCHA_ERROR
:
OCRResult.RECAPTCHA_ERROR:
this.isTerminated = true;
// await this.connect_to_browser(OCRResult.RECAPTCHA_ERROR)
break;
case
OCRResult.TO_SKIP
OCRResult.BRAVE_SKIP:
await this.handleBraveSkipBtn();
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_PRIVACY:
await this.device.shell("input tap " + 500 + " " + 1120)
await delay(2000);
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_PRIVACY_PUB:
await this.device.shell("input tap " + 455 + " " + 1920)
await delay(2000);
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_NOTIFICATION:
await this.device.shell("input tap " + 500 + " " + 1680)
await delay(2000);
await this.checkResultWithOcr();
break;
case OCRResult.TO_SKIP
:
logWithDevice("TO_SKIP", this.device)
if (this.device.model() === "21091116C")
this.device.shell("input tap " + 530 + " " + 1742)
await this.device.shell("input tap " + 530 + " " + 1742)
else
this.device.shell("input tap " + 488 + " " + 1848)
await this.device.shell("input tap " + 488 + " " + 1848)
await delay(2000);
break;
case
@@ -928,11 +945,8 @@ class CommandorPage {
OCRResult.GOOGLE_DISCONNECT
:
logWithDevice("GOOGLE_DISCONNECT", this.device)
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 this.tapGoogleDisconnectBtn()
await this.checkResultWithOcr();
break
case
@@ -969,6 +983,17 @@ class CommandorPage {
}
async handleBraveSkipBtn() {
if (this.device.model() === "CPH2219") {
await this.device.shell("input tap " + 558 + " " + 1160)
} else {
await this.device.shell("input tap " + 470 + " " + 1160)
}
await delay(2000);
await this.device.shell("input tap " + 455 + " " + 1920)
await delay(1000);
}
async clickOnConfirmBtn() {
if (this.device.model() === "CPH2219") {
this.device.shell("input tap " + 900 + " " + 1532)
@@ -1066,6 +1091,18 @@ class CommandorPage {
console.log(e)
}
}
async tapGoogleDisconnectBtn() {
if (this.device.model() === "MI 5s") {
if (this.browserPackageName.includes("brave"))
await this.device.shell("input tap " + 535 + " " + 1629)
else
await this.device.shell("input tap " + 550 + " " + 1740)
} else
await this.device.shell("input tap " + 411 + " " + 2100)
await delay(2000);
}
}
module