Merge branch 'feature/adb_open_url' of bitbucket.org:panleicim/puppeteerjs into feature/adb_open_url

This commit is contained in:
Lei PAN
2023-10-28 17:30:10 +02:00
2 changed files with 3 additions and 48 deletions
-45
View File
@@ -189,50 +189,6 @@ class CommandorPage {
console.log(e) console.log(e)
this.isTerminated = true; this.isTerminated = true;
} }
// Connect to the device.
if (this.browser) {
logWithDevice("browser.isConnected is " + this.browser.isConnected(), this.device);
}
try {
// logWithDevice("connecting to browser:" + this.port, this.device);
// while (this.browser === undefined || !this.browser.isConnected()) {
// this.browser = await puppeteer.connect({
// browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
// headless: false, defaultViewport: null
// })
// // let pages = await this.browser.pages();
// // this.page = pages[0];
// this.page = await this.browser.newPage();
//
// this.page.on("load", (loadedPage) => {
// this.onPageLoad(loadedPage);
// })
//
// this.page.on("response", (response) => {
// this.onResponse(response)
// })
// await delay(3 * 1000);
// }
} catch (e) {
logWithDevice("failed to connect to device", this.device)
console.log(e)
// await this.resetBrowser()
await this.checkResultWithOcr()
this.isTerminated = true
}
// if (this.page !== undefined) {
// try {
// logWithDevice("will open google", this.device)
// if (!this.isTerminated) {
// const item = searchTexts[Math.floor(Math.random() * searchTexts.length)];
// await this.page.goto("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 30 * 1000});
// }
// // await this.page.goto(RDV_URL, {timeout: 90 * 1000});
// } catch (e) {
// log(e)
// this.isTerminated = true
// }
// await this.acceptCookies(); // await this.acceptCookies();
await this.enableDisableAirPlanMode(); await this.enableDisableAirPlanMode();
// await delay(10 * 1000); // await delay(10 * 1000);
@@ -844,7 +800,6 @@ class CommandorPage {
this.isCountryChoosen = false; this.isCountryChoosen = false;
this.isPhoneInput = false; this.isPhoneInput = false;
this.isPasspordInput = false; this.isPasspordInput = false;
// this.disconnectBrowser();
await clearApp(this.device, this.browserPackageName) await clearApp(this.device, this.browserPackageName)
// await this.device.shell("pm clear " + this.browserPackageName) // await this.device.shell("pm clear " + this.browserPackageName)
await delay(1000) await delay(1000)
+3 -3
View File
@@ -113,6 +113,9 @@ class OCRChecker {
} else if (result.includes(BRAVE_NOTIFICATION)) { } else if (result.includes(BRAVE_NOTIFICATION)) {
await this.deleteFile(fileName) await this.deleteFile(fileName)
return OCRResult.BRAVE_NOTIFICATION 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)
return OCRResult.BRAVE_PRIVACY_PUB
} else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4) || result.includes(SLIDING_CAPTCHA_FR_5)) { } else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4) || result.includes(SLIDING_CAPTCHA_FR_5)) {
await this.deleteFile(fileName) await this.deleteFile(fileName)
// await this.deleteFile(screenShot) // await this.deleteFile(screenShot)
@@ -156,9 +159,6 @@ class OCRChecker {
} else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE) || result.includes(BRAVE_SKIP_PRIVACY_PAGE_2)) { } else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE) || result.includes(BRAVE_SKIP_PRIVACY_PAGE_2)) {
await this.deleteFile(fileName) await this.deleteFile(fileName)
return OCRResult.BRAVE_PRIVACY return OCRResult.BRAVE_PRIVACY
} 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)
return OCRResult.BRAVE_PRIVACY_PUB
} else { } else {
return OCRResult.TERMINAED return OCRResult.TERMINAED
} }