From 4ee264c650f22c26d58d4fbeefe6acc3b49509b3 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 24 Sep 2024 16:01:41 +0200 Subject: [PATCH] try to fix sliding probleme --- src/workers/CommandorPage.js | 41 ++++++++++++++++++------------------ src/workers/OCRChecker.js | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 1de0519..968fe3b 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -734,7 +734,7 @@ class CommandorPage { await delay(5000); } await this.slidingCaptchaSolver.solve(this.page, async (isSuccessful) => { - logWithDevice("check isAlwaysBlocked",this.device) + logWithDevice("check isAlwaysBlocked", this.device) this.isFillingFields = false onResult(isSuccessful) }) @@ -869,26 +869,6 @@ class CommandorPage { logWithDevice("will recheck OCR", this.device) checkResult = await this.ocrChecker.get_result(); } - - while (checkResult === OCRResult.SLIDING_CAPTCHA) { - logWithDevice("will call this.slidingCaptcha()", this.device) - await this.slidingCaptcha(async (isSuccessful) => { - logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device) - console.log(checkResult); - if (isSuccessful) { - await delay(5 * 1000) - checkResult = await this.ocrChecker.get_result(); - // await this.checkResultWithOcr() - } else { - await this.checkResultWithOcr() - // if (checkResult === OCRResult.SLIDING_CAPTCHA) { - // checkResult = OCRResult.TERMINAED - // this.isTerminated = true - // } - } - }) - await delay(10 * 1000) - } switch (checkResult) { case OCRResult.SLIDING_CAPTCHA_LOADING: this.isTerminated = true; @@ -902,6 +882,25 @@ class CommandorPage { case OCRResult.SLIDING_CAPTCHA_REFRESH: await this.connect_to_browser(checkResult) break; + case OCRResult.SLIDING_CAPTCHA: + logWithDevice("will call this.slidingCaptcha()", this.device) + await this.slidingCaptcha(async (isSuccessful) => { + logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device) + console.log(checkResult); + if (isSuccessful) { + await delay(5 * 1000) + // checkResult = await this.ocrChecker.get_result(); + await this.checkResultWithOcr() + } else { + await this.checkResultWithOcr() + // if (checkResult === OCRResult.SLIDING_CAPTCHA) { + // checkResult = OCRResult.TERMINAED + // this.isTerminated = true + // } + } + }) + // await delay(5 * 1000) + break; case OCRResult.FILL_FIELD: logWithDevice("FILL_FIELD", this.device) if (this.browser === undefined || !this.browser.isConnected()) { diff --git a/src/workers/OCRChecker.js b/src/workers/OCRChecker.js index fe4a4d3..d4891d7 100644 --- a/src/workers/OCRChecker.js +++ b/src/workers/OCRChecker.js @@ -213,7 +213,7 @@ class OCRChecker { async take_screen_shot() { let name = this.get_file_name() console.log("will take screenshot for " + this.device.model + ":" + this.device.serial) - console.log("name is " + name) + console.log("OCRChecker.name is " + name) let stdout1 = await exec("adb -s " + this.device.serial + " exec-out screencap -p > " + name) await delay(5000); console.log(`stdout: ${stdout1}`);