remove playwright

This commit is contained in:
2024-09-24 13:59:18 +02:00
parent 0115ad7139
commit 32f8b9812d
7 changed files with 153 additions and 138 deletions
+54 -59
View File
@@ -59,19 +59,19 @@ function log(message) {
}
async function clearApp(device, packageName) {
let cmd = `adb -s ${device.serial()} shell pm clear ${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}`
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})
appointmentLogger.log({level: "info", message: device.model + ":" + device.serial + ":" + message})
}
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
@@ -195,9 +195,9 @@ class CommandorPage {
}
async loadPage() {
logWithDevice(this.device.serial() + ":loadPage() called, with port:" + this.port, this.device);
logWithDevice(this.device.serial + ":loadPage() called, with port:" + this.port, this.device);
try {
// let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
// 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")
@@ -218,7 +218,7 @@ class CommandorPage {
let cancel
const intervalTask = setInterval(async () => {
if (this.isTerminated) {
log(this.device.model() + ":request terminated, send cancel()");
logWithDevice(":request terminated, send cancel()", this.device)
try {
if (this.page !== undefined && !this.page.isClosed()) {
await this.page.close()
@@ -634,11 +634,6 @@ class CommandorPage {
async resolveCaptcha(page) {
logWithDevice("resolveCaptcha", this.device)
if (RDV_URL.includes("192")) {
// await this.push_message_to_queue(PublishType.SUCCESS)
await delay(100000)
return
}
try {
//check whether there is captcha
let pageContent = await page.content()
@@ -733,8 +728,8 @@ class CommandorPage {
async slidingCaptcha(onResult) {
logWithDevice("slidingCaptcha", this.device);
if (this.device.model() === "MI 5s" || this.device.model() === "ASUS_X00QD" || this.device.model() === "ASUS_Z012D" || this.device.model() === "HUAWEI NXT-TL00") {
let cmd = `adb -s ${this.device.serial()} shell input touchscreen swipe 900 495 900 195`
if (this.device.model === "MI 5s" || this.device.model === "ASUS_X00QD" || this.device.model === "ASUS_Z012D" || this.device.model === "HUAWEI NXT-TL00") {
let cmd = `adb -s ${this.device.serial} shell input touchscreen swipe 900 495 900 195`
await exec(cmd);
await delay(5000);
}
@@ -781,9 +776,9 @@ 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.source_from = this.device.model;
reserve.currentIp = currentIp
reserve.serial = this.device.serial();
reserve.serial = this.device.serial;
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
if (!this.page.isClosed()) {
try {
@@ -862,7 +857,7 @@ class CommandorPage {
async checkResultWithOcr() {
logWithDevice("checkResultWithOcr() called.", this.device)
if (this.device.model() === "M2006C3LG")
if (this.device.model === "M2006C3LG")
await delay(6000);
else {
await delay(4000);
@@ -999,23 +994,23 @@ class CommandorPage {
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_PRIVACY:
let model = this.device.model()
if (model === "MI 5s" || this.device.model() === "SM-G965U1" || this.device.model() === "ASUS_Z012D") {
let model = this.device.model
if (model === "MI 5s" || this.device.model === "SM-G965U1" || this.device.model === "ASUS_Z012D") {
await this.tapForDevice(this.device, 530, 970)
} else if (model === "HUAWEI NXT-TL00") {
await this.tapForDevice(this.device, 530, 950)
} else if (this.device.model() === "ONEPLUS A6000") {
} else if (this.device.model === "ONEPLUS A6000") {
await this.tapForDevice(this.device, 530, 1064)
} else if (this.device.model() === "moto g51 5G") {
} else if (this.device.model === "moto g51 5G") {
await this.tapForDevice(this.device, 500, 1080)
} else if (this.device.model() === "CPH2469") {
} else if (this.device.model === "CPH2469") {
await this.tapForDevice(this.device, 360, 820)
} else if (this.device.model() === "M2006C3LG" || this.device.model() === "220233L2G") {
} else if (this.device.model === "M2006C3LG" || this.device.model === "220233L2G") {
await this.tapForDevice(this.device, 350, 777)
} else if (this.device.model() === "KB2003") {
} else if (this.device.model === "KB2003") {
await this.tapForDevice(this.device, 500, 1200)
await this.tapForDevice(this.device, 500, 1120)
} else if (this.device.model() === "DE2117") {
} else if (this.device.model === "DE2117") {
await this.tapForDevice(this.device, 545, 1130)
} else
try {
@@ -1028,9 +1023,9 @@ class CommandorPage {
await this.checkResultWithOcr();
break;
case OCRResult.BRAVE_PRIVACY_PUB:
if (this.device.model() === "MI 5s" || this.device.model() === "ASUS_Z012D") {
if (this.device.model === "MI 5s" || this.device.model === "ASUS_Z012D") {
await this.tapForDevice(this.device, 60, 1400)
} else if (this.device.model() === "HUAWEI NXT-TL00") {
} else if (this.device.model === "HUAWEI NXT-TL00") {
await this.tapForDevice(this.device, 530, 950)
} else
await this.tapForDevice(this.device, 455, 1920)
@@ -1045,11 +1040,11 @@ class CommandorPage {
break
case OCRResult.BRAVE_NOTIFICATION:
logWithDevice("BRAVE_NOTIFICATION", this.device)
if (this.device.model() === "21091116C") {
if (this.device.model === "21091116C") {
await this.tapForDevice(this.device, 540, 1611)
} else if (this.device.model() === "22041219PG") {
} else if (this.device.model === "22041219PG") {
await this.tapForDevice(this.device, 530, 1600)
} else if (this.device.model() === "CPH2469") {
} else if (this.device.model === "CPH2469") {
await this.tapForDevice(this.device, 322, 1146)
} else
await this.tapForDevice(this.device, 500, 1680)
@@ -1066,14 +1061,14 @@ class CommandorPage {
break;
case OCRResult.BRAVE_VPN_SKIP:
logWithDevice("BRAVE_VPN_SKIP", this.device)
if (this.device.model() === "M2006C3LG") {
if (this.device.model === "M2006C3LG") {
await this.tapForDevice(this.device, 580, 445)
}
break;
case OCRResult.TO_SKIP
:
logWithDevice("TO_SKIP", this.device)
if (this.device.model() === "21091116C" || this.device.model() === "22041219PG") {
if (this.device.model === "21091116C" || this.device.model === "22041219PG") {
await this.tapForDevice(this.device, 530, 1742)
await delay(1000);
await this.tapForDevice(this.device, 530, 1742)
@@ -1309,7 +1304,7 @@ class CommandorPage {
}
async handleBraveSkipBtn() {
let model = this.device.model()
let model = this.device.model
if (model === "CPH2219") {
await this.tapForDevice(this.device, 558, 1160)
} else if (model === "MI 5s" || model === "ASUS_Z012D") {
@@ -1334,32 +1329,32 @@ class CommandorPage {
}
async tapForDevice(device, x, y) {
let cmd = `adb -s ${device.serial()} shell input tap ${x} ${y}`
let cmd = `adb -s ${device.serial} shell input tap ${x} ${y}`
logWithDevice("cmd is " + cmd, this.device)
await exec(cmd);
}
async swipeForDevice(device, x0, y0, x1, y1) {
// let swipCmd = "input swipe " + x + " " + y0 + " " + x + " 1522"
let cmd = `adb -s ${device.serial()} shell input swipe ${x0} ${y0} ${x1} ${y1}`
let cmd = `adb -s ${device.serial} shell input swipe ${x0} ${y0} ${x1} ${y1}`
logWithDevice("cmd is " + cmd, this.device)
await exec(cmd);
}
async inputForDevice(device, text) {
let cmd = `adb -s ${device.serial()} shell input text ${text}`
let cmd = `adb -s ${device.serial} shell input text ${text}`
logWithDevice("cmd is " + cmd, this.device)
await exec(cmd);
}
async clickOnConfirmBtn() {
if (this.device.model() === "CPH2219") {
if (this.device.model === "CPH2219") {
this.device.shell("input tap " + 900 + " " + 1532)
} else if (this.device.model() === "MI 5s") {
} else if (this.device.model === "MI 5s") {
this.device.shell("input tap " + 925 + " " + 1325)
} else if (this.device.model() === "22041219PG") {
} else if (this.device.model === "22041219PG") {
this.device.shell("input tap " + 925 + " " + 1430)
} else if (this.device.model() === "moto g51 5G") {
} else if (this.device.model === "moto g51 5G") {
await this.tapForDevice(this.device, 950, 1434)
} else
this.device.shell("input tap " + 933 + " " + 1538)
@@ -1368,35 +1363,35 @@ class CommandorPage {
async clickOnHomeBtn() {
// await this.enableDisableAirPlanMode()
if (this.device.model() === "22041219PG") {
if (this.device.model === "22041219PG") {
await this.tapForDevice(this.device, 110, 2208)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "KB2003") {
} else if (this.device.model === "KB2003") {
await this.tapForDevice(this.device, 100, 2289)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "21091116C") {
} else if (this.device.model === "21091116C") {
await this.tapForDevice(this.device, 107, 2193)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "MI 5s") {
} else if (this.device.model === "MI 5s") {
await this.tapForDevice(this.device, 110, 1842)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "ASUS_X00QD" || this.device.model() === "CPH2219") {
} else if (this.device.model === "ASUS_X00QD" || this.device.model === "CPH2219") {
await this.tapForDevice(this.device, 112, 2172)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "moto g51 5G") {
} else if (this.device.model === "moto g51 5G") {
await this.tapForDevice(this.device, 103, 2283)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "ONEPLUS A6000") {
} else if (this.device.model === "ONEPLUS A6000") {
await this.tapForDevice(this.device, 122, 2172)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
} else if (this.device.model() === "DE2117") {
} else if (this.device.model === "DE2117") {
await this.tapForDevice(this.device, 122, 2172)
await delay(2000);
await openUrlWithAdb(RDV_URL, this.device)
@@ -1410,7 +1405,7 @@ class CommandorPage {
async skipOptimizationPage() {
logWithDevice("skipOptimizationPage", this.device)
let model = this.device.model();
let model = this.device.model;
if (model === "ASUS_X00QD") {
this.device.shell("input tap " + 800 + " " + 2100)
await delay(2000);
@@ -1440,7 +1435,7 @@ class CommandorPage {
async tapLaterBtn() {
logWithDevice("tapLaterBtn", this.device)
let model = this.device.model();
let model = this.device.model;
log("model is " + model);
if (model === "CPH2219") {
this.device.shell("input tap " + 385 + " " + 1930)
@@ -1488,27 +1483,27 @@ class CommandorPage {
}
async tapGoogleDisconnectBtn() {
if (this.device.model() === "MI 5s") {
if (this.device.model === "MI 5s") {
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") {
if (this.browserPackageName.includes("brave") && this.device.model === "CPH2219") {
await this.device.shell("input tap " + 411 + " " + 1977)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "RMX3151") {
} else if (this.browserPackageName.includes("brave") && this.device.model === "RMX3151") {
await this.device.shell("input tap " + 411 + " " + 1977)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "ONEPLUS A6000") {
} 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") {
} 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") {
} else if (this.browserPackageName.includes("brave") && this.device.model === "22041219PG") {
await this.tapForDevice(this.device, 411, 2020)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "21091116C") {
} else if (this.browserPackageName.includes("brave") && this.device.model === "21091116C") {
await this.tapForDevice(this.device, 411, 2020)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "M2006C3LG") {//redmi 9a
} else if (this.browserPackageName.includes("brave") && this.device.model === "M2006C3LG") {//redmi 9a
await this.tapForDevice(this.device, 411, 1300)
} else if (this.browserPackageName.includes("brave") && this.device.model() === "220233L2G") {//redmi 9a
} else if (this.browserPackageName.includes("brave") && this.device.model === "220233L2G") {//redmi 9a
await this.tapForDevice(this.device, 411, 1300)
} else {
await this.tapForDevice(this.device, 411, 2100)
@@ -1536,7 +1531,7 @@ class CommandorPage {
}
async handleBravePushNotification() {
let model = this.device.model()
let model = this.device.model
if (model === "KB2003" || model === "22041219PG" || model === "DE2117" || model === "21091116C") {
await this.tapForDevice(this.device, 545, 1448)
} else