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
+2
View File
@@ -15,6 +15,7 @@ class ReserveResultPojo {
this.email = mail; this.email = mail;
this.type = type; this.type = type;
this.source_from = "" this.source_from = ""
this.serial = ""
this.hostName = hostName this.hostName = hostName
this.created_at = new Date().toLocaleString() this.created_at = new Date().toLocaleString()
} }
@@ -30,6 +31,7 @@ class ReserveResultPojo {
url: this.url, url: this.url,
store_type: this.storeType, store_type: this.storeType,
source_from: this.source_from, source_from: this.source_from,
serial: this.serial,
created_at: this.created_at, created_at: this.created_at,
hostName: this.hostName hostName: this.hostName
} }
+28 -2
View File
@@ -91,6 +91,7 @@ class CommandorPage {
this.isCountryChoosen = false; this.isCountryChoosen = false;
this.isPhoneInput = false; this.isPhoneInput = false;
this.firstStart = true; this.firstStart = true;
this.isAlreadyRefresh = false;
} }
async connect_to_browser(ocrResult) { 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() { async checkIfSuccessful() {
let content = await this.page.content(); let content = await this.page.content();
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
@@ -167,7 +185,9 @@ class CommandorPage {
} }
// await this.acceptCookies(); // await this.acceptCookies();
await this.enableDisableAirPlanMode(); 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 openUrlWithAdb(RDV_URL, this.device)
await delay(10 * 1000) await delay(10 * 1000)
await this.checkResultWithOcr() await this.checkResultWithOcr()
@@ -715,6 +735,7 @@ class CommandorPage {
// save to mongoDb // save to mongoDb
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType); let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
reserve.source_from = this.device.model(); reserve.source_from = this.device.model();
reserve.serial = this.device.serial();
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict()) await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
if (!this.page.isClosed()) { if (!this.page.isClosed()) {
try { try {
@@ -1036,7 +1057,12 @@ class CommandorPage {
case case
OCRResult.BLOCKED OCRResult.BLOCKED
: :
await this.resetBrowser(); if (this.isAlreadyRefresh) {
await this.resetBrowser();
} else {
this.isAlreadyRefresh = true;
await this.generateRandomActions()
}
break; break;
case case
OCRResult.ONLINE_APPOINTMENT OCRResult.ONLINE_APPOINTMENT