Merge branch 'master' into feature/macOcr

This commit is contained in:
2023-10-25 16:22:43 +02:00
5 changed files with 78 additions and 51 deletions
+54 -27
View File
@@ -54,6 +54,18 @@ function log(message) {
appointmentLogger.log({level: "info", message: message})
}
async function clearApp(device, packageName) {
let cmd = `adb -s ${device.serial()} shell pm clear ${packageName}`
logWithDevice("cmd is " + cmd, device)
await exec(cmd);
}
async function exceutShellCmd(device, cmdToExecut) {
let cmd = `adb -s ${device.serial()} shell ${cmdToExecut}`
logWithDevice("cmd is " + cmd, device)
await exec(cmd);
}
function logWithDevice(message, device) {
appointmentLogger.log({level: "info", message: device.model() + ":" + device.serial() + ":" + message})
}
@@ -145,8 +157,11 @@ class CommandorPage {
async loadPage() {
logWithDevice(this.device.serial() + ":loadPage() called, with port:" + this.port, this.device);
try {
await this.device.shell("am start -n " + this.browserPackageName + "/com.google.android.apps.chrome.Main")
await delay(5 * 1000);
// let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
await exceutShellCmd(this.device, " forward tcp:" + this.port + " localabstract:chrome_devtools_remote")
await delay(1 * 1000);
await this.startPage(this.device, this.browserPackageName + "/com.google.android.apps.chrome.Main")
await delay(4 * 1000);
} catch (e) {
console.log(e)
this.isTerminated = true;
@@ -200,9 +215,6 @@ class CommandorPage {
await this.enableDisableAirPlanMode();
await delay(10 * 1000);
await this.clickOnlineAppointment();
// await delay(2000);
// if (!this.isTerminated)
// await this.clickOnlineAppointment();
} else {
this.isTerminated = true;
}
@@ -812,7 +824,8 @@ class CommandorPage {
this.isPhoneInput = false;
this.isPasspordInput = false;
// this.disconnectBrowser();
await this.device.shell("pm clear " + this.browserPackageName)
await clearApp(this.device, this.browserPackageName)
// await this.device.shell("pm clear " + this.browserPackageName)
await delay(1000)
this.isTerminated = true;
// await this.checkResultWithOcr();
@@ -988,9 +1001,10 @@ class CommandorPage {
// await this.device.shell("input tap " + 530 + " " + 970)
} else if (this.device.model() === "ONEPLUS A6000")
await this.device.shell("input tap " + 530 + " " + 1064)
else if (this.device.model() === "KB2003")
else if (this.device.model() === "KB2003" || this.device.model() === "DE2117") {
await this.tapForDevice(this.device, 500, 1200)
else
await this.tapForDevice(this.device, 500, 1120)
} else
try {
await this.tapForDevice(this.device, 500, 1120)
// await this.device.shell("input tap " + 500 + " " + 1120)
@@ -1001,21 +1015,22 @@ class CommandorPage {
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_PRIVACY_PUB:
if (this.device.model() === "MI 5s")
await this.device.shell("input tap " + 60 + " " + 1400)
else
if (this.device.model() === "MI 5s") {
await this.tapForDevice(this.device, 60, 1400)
} else
await this.tapForDevice(this.device, 455, 1920)
await delay(2000);
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_NOTIFICATION:
logWithDevice("BRAVE_NOTIFICATION", this.device)
if (this.device.model() === "21091116C")
await this.device.shell("input tap " + 540 + " " + 1611)
else if (this.device.model() === "22041219PG")
await this.device.shell("input tap " + 530 + " " + 1600)
else
await this.device.shell("input tap " + 500 + " " + 1680)
if (this.device.model() === "21091116C") {
await this.tapForDevice(this.device, 540, 1611)
} else if (this.device.model() === "22041219PG") {
await this.tapForDevice(this.device, 530, 1600)
} else
await this.tapForDevice(this.device, 500, 1680)
// await this.device.shell("input tap " + 500 + " " + 1680)
await delay(2000);
await this.checkResultWithOcr();
break;
@@ -1211,11 +1226,11 @@ class CommandorPage {
async enableDisableAirPlanMode() {
logWithDevice("will enable/disable airplane mode", this.device)
try {
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("cmd connectivity airplane-mode enable")
await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
await delay(1000)
// await this.device.shell("adb shell settings put global airplane_mode_on 0")
await this.device.shell("cmd connectivity airplane-mode disable")
await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
// await this.device.shell("cmd connectivity airplane-mode disable")
await delay(2000)
} catch (e) {
try {
@@ -1229,9 +1244,9 @@ class CommandorPage {
async tapGoogleDisconnectBtn() {
if (this.device.model() === "MI 5s") {
if (this.browserPackageName.includes("brave"))
await this.device.shell("input tap " + 535 + " " + 1629)
else
if (this.browserPackageName.includes("brave")) {
await this.tapForDevice(this.device, 535, 1629)
} else
await this.device.shell("input tap " + 550 + " " + 1740)
} else {
if (this.browserPackageName.includes("brave") && this.device.model() === "CPH2219") {
@@ -1240,13 +1255,25 @@ class CommandorPage {
await this.device.shell("input tap " + 411 + " " + 1977)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "ONEPLUS A6000") {
await this.device.shell("input tap " + 411 + " " + 1970)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "ASUS_X00QD") {
await this.device.shell("input tap " + 411 + " " + 1970)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "22041219PG") {
await this.device.shell("input tap " + 411 + " " + 2020)
} else
await this.device.shell("input tap " + 411 + " " + 2100)
await this.tapForDevice(this.device, 411, 2020)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "21091116C") {
await this.tapForDevice(this.device, 411, 2020)
} else {
await this.tapForDevice(this.device, 411, 2100)
}
// await this.device.shell("input tap " + 411 + " " + 2100)
}
await delay(2000);
}
async startPage(device, activity) {
let cmd = `adb -s ${device.serial()} shell am start -n ${activity}`
logWithDevice("cmd is " + cmd, this.device)
await exec(cmd);
}
}
module
+4
View File
@@ -95,6 +95,10 @@ class OCRChecker {
await this.deleteFile(fileName)
// await this.deleteFile(screenShot)
return OCRResult.SUCCESS
} else if (result.includes(BRAVE_NOTIFICATION)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.BRAVE_NOTIFICATION
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5)) {
await this.deleteFile(fileName)
// await this.deleteFile(screenShot)
-5
View File
@@ -102,11 +102,6 @@ class SlidingCaptchaSolver {
let result = response.data;
console.log(result);
await callback(result);
// console.log("will delete png file: " + fileName);
// await fs.unlink(fileName, (err) => {
// if (err) throw err;
// console.log(fileName + ' was deleted');
// })
} else {
console.log("error");
await callback([]);