add serial number and random actions

This commit is contained in:
Lei PAN
2024-02-17 12:06:25 +01:00
parent aea402d11e
commit 6d58a39fc9
2 changed files with 30 additions and 2 deletions
+28 -2
View File
@@ -91,6 +91,7 @@ class CommandorPage {
this.isCountryChoosen = false;
this.isPhoneInput = false;
this.firstStart = true;
this.isAlreadyRefresh = false;
}
async connect_to_browser(ocrResult) {
@@ -142,6 +143,23 @@ class CommandorPage {
}
}
async generateRandomActions() {
logWithDevice("will reload page", this.device)
await this.handleBraveSkipBtn()
await delay(1000);
let cmd = "input swipe 382 482 382 1682"
logWithDevice("will send cmd:" + cmd, this.device)
this.device.shell(cmd);
await delay(2000);
let limit = getRandom()
for (let i = 1; i <= limit; i++) {
this.device.shell(cmd);
await delay(1000);
}
await this.clickOnConfirmBtn();
await this.checkResultWithOcr();
}
async checkIfSuccessful() {
let content = await this.page.content();
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
@@ -167,7 +185,9 @@ class CommandorPage {
}
// await this.acceptCookies();
await this.enableDisableAirPlanMode();
// await delay(10 * 1000);
// await openUrlWithAdb("https://www.google.fr", this.device)
// await delay(2 * 1000)
await openUrlWithAdb(RDV_URL, this.device)
await delay(10 * 1000)
await this.checkResultWithOcr()
@@ -715,6 +735,7 @@ class CommandorPage {
// save to mongoDb
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
reserve.source_from = this.device.model();
reserve.serial = this.device.serial();
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
if (!this.page.isClosed()) {
try {
@@ -1036,7 +1057,12 @@ class CommandorPage {
case
OCRResult.BLOCKED
:
await this.resetBrowser();
if (this.isAlreadyRefresh) {
await this.resetBrowser();
} else {
this.isAlreadyRefresh = true;
await this.generateRandomActions()
}
break;
case
OCRResult.ONLINE_APPOINTMENT