use adb insead of playwright
This commit is contained in:
@@ -981,7 +981,12 @@ class CommandorPage {
|
||||
else if (this.device.model() === "ONEPLUS A6000")
|
||||
await this.device.shell("input tap " + 530 + " " + 1064)
|
||||
else
|
||||
await this.device.shell("input tap " + 500 + " " + 1120)
|
||||
try {
|
||||
await this.tapForDevice(this.device, 500, 1120)
|
||||
// await this.device.shell("input tap " + 500 + " " + 1120)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
await delay(2000);
|
||||
await this.checkResultWithOcr();
|
||||
break;
|
||||
@@ -1092,13 +1097,21 @@ class CommandorPage {
|
||||
} else if (model === "ONEPLUS A6000") {
|
||||
await this.device.shell("input tap " + 530 + " " + 1106)
|
||||
} else {
|
||||
await this.device.shell("input tap " + 470 + " " + 1160)
|
||||
logWithDevice("handleBraveSkipBtn", this.device)
|
||||
await this.tapForDevice(this.device, 470, 1160)
|
||||
// await this.device.shell("input tap " + 470 + " " + 1160)
|
||||
}
|
||||
await delay(2000);
|
||||
await this.device.shell("input tap " + 455 + " " + 1920)
|
||||
await this.tapForDevice(this.device, 455, 1920)
|
||||
// await this.device.shell("input tap " + 455 + " " + 1920)
|
||||
await delay(1000);
|
||||
}
|
||||
|
||||
async tapForDevice(device, x, y) {
|
||||
let cmd = `adb -s ${device.serial()} shell input tap ${x} ${y}`
|
||||
await exec(cmd);
|
||||
}
|
||||
|
||||
async clickOnConfirmBtn() {
|
||||
if (this.device.model() === "CPH2219") {
|
||||
this.device.shell("input tap " + 900 + " " + 1532)
|
||||
|
||||
@@ -3,6 +3,7 @@ const tesseract = require("node-tesseract-ocr");
|
||||
const OCRResult = require("../models/OCRResult");
|
||||
const Jimp = require('jimp');
|
||||
const fs = require("fs");
|
||||
const {exec} = require("child_process");
|
||||
|
||||
function delay(delayInMs) {
|
||||
return new Promise(resolve => {
|
||||
@@ -69,7 +70,8 @@ const BRAVE_SKIP_DEFAULT_PAGE_2 = "définissant Brave"
|
||||
const BRAVE_SKIP_PRIVACY_PAGE = "Partagez des informations"
|
||||
const BRAVE_SKIP_PRIVACY_PAGE_2 = "Partagez des renseignements"
|
||||
|
||||
async function convertImageToWhiteBlack(image_path) {
|
||||
async function convertImageToWhiteBlack(image_path, device) {
|
||||
console.log("convertImageToWhiteBlack for " + device.serial())
|
||||
const image = await Jimp.read(image_path);
|
||||
image.grayscale().write(image_path + ".wb");
|
||||
return image_path + ".wb";
|
||||
@@ -90,7 +92,7 @@ class OCRChecker {
|
||||
|
||||
async get_result() {
|
||||
let fileName = await this.take_screen_shot()
|
||||
let screenShot = await convertImageToWhiteBlack(fileName);
|
||||
let screenShot = await convertImageToWhiteBlack(fileName, this.device);
|
||||
await delay(1000)
|
||||
try {
|
||||
let result = await tesseract
|
||||
@@ -172,9 +174,11 @@ class OCRChecker {
|
||||
await this.deleteFile(screenShot)
|
||||
return OCRResult.BRAVE_NOTIFICATION
|
||||
} else if (result.includes(BRAVE_SKIP_PUB) || result.includes(BRAVE_SKIP_PUB_2) || result.includes(BRAVE_SKIP_PUB_3) || result.includes(BRAVE_SKIP_PUB_4) || result.includes(BRAVE_SKIP_PUB_5)) {
|
||||
await this.deleteFile(fileName)
|
||||
await this.deleteFile(screenShot)
|
||||
return OCRResult.BRAVE_PRIVACY_PUB
|
||||
} else {
|
||||
return OCRResult.TERMINAED
|
||||
return OCRResult.TERMINAED``
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -194,8 +198,10 @@ class OCRChecker {
|
||||
async take_screen_shot() {
|
||||
let name = this.get_file_name()
|
||||
console.log("will take screenshot for " + this.device.model() + ":" + this.device.serial())
|
||||
await this.device.screenshot({path: name});
|
||||
await delay(3000);
|
||||
let stdout1 = await exec("adb -s " + this.device.serial() + " exec-out screencap -p > " + name)
|
||||
await delay(5000);
|
||||
console.log(`stdout: ${stdout1}`);
|
||||
// await this.device.screenshot({path: name});
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user