try to close page
This commit is contained in:
@@ -200,9 +200,9 @@ class CommandorPage {
|
|||||||
if (this.isTerminated) {
|
if (this.isTerminated) {
|
||||||
log(this.device.model() + ":request terminated, send cancel()");
|
log(this.device.model() + ":request terminated, send cancel()");
|
||||||
// this.resetBrowser();
|
// this.resetBrowser();
|
||||||
|
this.disconnectBrowser();
|
||||||
clearInterval(intervalTask)
|
clearInterval(intervalTask)
|
||||||
cancel()
|
cancel()
|
||||||
// return this.browser
|
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
}, 10 * 1000)//interval of 10 seconds
|
}, 10 * 1000)//interval of 10 seconds
|
||||||
@@ -319,7 +319,7 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
await page.keyboard.type("" + this.contact.phoneNumber);
|
await page.keyboard.type("0" + this.contact.phoneNumber);
|
||||||
this.isPhoneInput = true;
|
this.isPhoneInput = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -625,6 +625,7 @@ class CommandorPage {
|
|||||||
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
|
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();
|
||||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||||
|
await this.page.close();
|
||||||
// await this.deleteFromBlackList()
|
// await this.deleteFromBlackList()
|
||||||
// await this.resetBrowser()
|
// await this.resetBrowser()
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
@@ -723,8 +724,8 @@ class CommandorPage {
|
|||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
break;
|
break;
|
||||||
case OCRResult.FILL_FIELD:
|
case OCRResult.FILL_FIELD:
|
||||||
console.log("browser.isConnected: " + this.browser.isConnected());
|
// console.log("browser.isConnected: " + this.browser.isConnected());
|
||||||
if (!this.browser.isConnected()) {
|
if (this.browser === undefined || !this.browser.isConnected()) {
|
||||||
logWithDevice("trying to connect to browser", this.device)
|
logWithDevice("trying to connect to browser", this.device)
|
||||||
try {
|
try {
|
||||||
this.browser = await puppeteer.connect({
|
this.browser = await puppeteer.connect({
|
||||||
@@ -850,6 +851,8 @@ class CommandorPage {
|
|||||||
log("model is " + model);
|
log("model is " + model);
|
||||||
if (model === "CPH2219") {
|
if (model === "CPH2219") {
|
||||||
this.device.shell("input tap " + 385 + " " + 1930)
|
this.device.shell("input tap " + 385 + " " + 1930)
|
||||||
|
} else if (model === "ASUS_X00QD") {
|
||||||
|
this.device.shell("input tap " + 490 + " " + 1910)
|
||||||
} else
|
} else
|
||||||
this.device.shell("input tap " + 385 + " " + 2050)
|
this.device.shell("input tap " + 385 + " " + 2050)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ const config = {
|
|||||||
psm: 3,
|
psm: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
const MESSAGE_URL_VALIDATION_FR = "Nous avons envoyé un lien par e-mail."
|
const MESSAGE_URL_VALIDATION_FR = "envoyé un lien par e-mail."
|
||||||
|
const MESSAGE_URL_VALIDATION_FR_2 = "un lien par e-mail"
|
||||||
const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email"
|
const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email"
|
||||||
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||||
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
||||||
@@ -66,7 +67,7 @@ class OCRChecker {
|
|||||||
let result = await tesseract
|
let result = await tesseract
|
||||||
.recognize(screenShot, config)
|
.recognize(screenShot, config)
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR)) {
|
if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR) || result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
||||||
return OCRResult.SUCCESS
|
return OCRResult.SUCCESS
|
||||||
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
||||||
return OCRResult.RECAPTCHA_ERROR
|
return OCRResult.RECAPTCHA_ERROR
|
||||||
@@ -96,6 +97,8 @@ class OCRChecker {
|
|||||||
return OCRResult.TO_SKIP
|
return OCRResult.TO_SKIP
|
||||||
} else if (result.includes(GOOGLE_DISCONNECT_FR)) {
|
} else if (result.includes(GOOGLE_DISCONNECT_FR)) {
|
||||||
return OCRResult.GOOGLE_DISCONNECT
|
return OCRResult.GOOGLE_DISCONNECT
|
||||||
|
} else {
|
||||||
|
return OCRResult.TERMINAED
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user