support new version
This commit is contained in:
@@ -11,6 +11,7 @@ const {exec} = require("child_process");
|
|||||||
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
||||||
const RequestDataPojo = require("../models/RequestDataPojo");
|
const RequestDataPojo = require("../models/RequestDataPojo");
|
||||||
const {REQUEST_DATA_OBJECT, TEST_QUEUE} = require("../queue/Sender");
|
const {REQUEST_DATA_OBJECT, TEST_QUEUE} = require("../queue/Sender");
|
||||||
|
const {page} = require("yarn/lib/cli");
|
||||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||||
const BLANK_URL = "about:blank"
|
const BLANK_URL = "about:blank"
|
||||||
@@ -50,6 +51,12 @@ function getRandom() {
|
|||||||
return Math.floor(Math.random() * 3);
|
return Math.floor(Math.random() * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRandomId() {
|
||||||
|
let _list = [PASSPORT_ID, EMAIL_ID, FIRST_NAME, LAST_NAME];
|
||||||
|
let index = Math.floor(Math.random() * _list.length);
|
||||||
|
return _list[index];
|
||||||
|
}
|
||||||
|
|
||||||
function getRandomWaitTime() {
|
function getRandomWaitTime() {
|
||||||
return getRandom() * 1000
|
return getRandom() * 1000
|
||||||
}
|
}
|
||||||
@@ -401,12 +408,12 @@ class CommandorPage {
|
|||||||
// await page.focus(LAST_NAME);
|
// await page.focus(LAST_NAME);
|
||||||
await delay(getRandomWaitTime());
|
await delay(getRandomWaitTime());
|
||||||
console.log("will clear surname field");
|
console.log("will clear surname field");
|
||||||
await page.evaluate(() => {
|
// await page.evaluate(() => {
|
||||||
let field = document.getElementById("surname");
|
// let field = document.getElementById("surname");
|
||||||
if (field) {
|
// if (field) {
|
||||||
field.value = ""
|
// field.value = ""
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
// await page.keyboard.type(this.contact.lastName);
|
// await page.keyboard.type(this.contact.lastName);
|
||||||
await page.evaluate((lastName) => {
|
await page.evaluate((lastName) => {
|
||||||
@@ -422,7 +429,6 @@ class CommandorPage {
|
|||||||
let field = document.getElementById("name");
|
let field = document.getElementById("name");
|
||||||
if (field) {
|
if (field) {
|
||||||
field.value = firstName;
|
field.value = firstName;
|
||||||
// field.value = ""
|
|
||||||
}
|
}
|
||||||
}, this.contact.firstName)
|
}, this.contact.firstName)
|
||||||
// await page.keyboard.type(this.contact.firstName);
|
// await page.keyboard.type(this.contact.firstName);
|
||||||
@@ -505,10 +511,8 @@ class CommandorPage {
|
|||||||
document.querySelector("#cgu").checked = true
|
document.querySelector("#cgu").checked = true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// await page.click(CGU_ID);
|
|
||||||
await delay(getRandomWaitTime());
|
await delay(getRandomWaitTime());
|
||||||
await page.focus(PROCESSING_ID);
|
await page.focus(PROCESSING_ID);
|
||||||
// await page.click(PROCESSING_ID)
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
if (!document.querySelector("#processing").checked) {
|
if (!document.querySelector("#processing").checked) {
|
||||||
document.querySelector("#processing").checked = true
|
document.querySelector("#processing").checked = true
|
||||||
@@ -581,8 +585,12 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async clickValid() {
|
async clickValid() {
|
||||||
logWithDevice("clickValid() called.", this.device);
|
logWithDevice("clickValid() called.", this.device);
|
||||||
|
let _id_to_click = getRandomId()
|
||||||
|
await this.page.click(_id_to_click)
|
||||||
|
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
this.isFillingFields = false
|
this.isFillingFields = false
|
||||||
try {
|
try {
|
||||||
@@ -612,7 +620,7 @@ class CommandorPage {
|
|||||||
this.contact.firstName = raw.firstName
|
this.contact.firstName = raw.firstName
|
||||||
}
|
}
|
||||||
await this.page.evaluate(() => {
|
await this.page.evaluate(() => {
|
||||||
document.getElementsByClassName("btn")[0].click();
|
document.getElementsByTagName("button")[1].click();
|
||||||
})
|
})
|
||||||
if (this.firstStart) {
|
if (this.firstStart) {
|
||||||
this.disconnectBrowser();
|
this.disconnectBrowser();
|
||||||
@@ -889,18 +897,20 @@ class CommandorPage {
|
|||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
break;
|
break;
|
||||||
case OCRResult.SLIDING_CAPTCHA:
|
case OCRResult.SLIDING_CAPTCHA:
|
||||||
logWithDevice("will call this.slidingCaptcha()", this.device)
|
this.isAlreadyRefresh = true;
|
||||||
await this.slidingCaptcha(async (isSuccessful) => {
|
await this.generateRandomActions()
|
||||||
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
// logWithDevice("will call this.slidingCaptcha()", this.device)
|
||||||
console.log(checkResult);
|
// await this.slidingCaptcha(async (isSuccessful) => {
|
||||||
if (isSuccessful) {
|
// logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
||||||
await delay(5 * 1000)
|
// console.log(checkResult);
|
||||||
// checkResult = await this.ocrChecker.get_result();
|
// if (isSuccessful) {
|
||||||
await this.checkResultWithOcr()
|
// await delay(5 * 1000)
|
||||||
} else {
|
// // checkResult = await this.ocrChecker.get_result();
|
||||||
await this.checkResultWithOcr()
|
// await this.checkResultWithOcr()
|
||||||
}
|
// } else {
|
||||||
})
|
// await this.checkResultWithOcr()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
// await delay(5 * 1000)
|
// await delay(5 * 1000)
|
||||||
break;
|
break;
|
||||||
case OCRResult.FILL_FIELD:
|
case OCRResult.FILL_FIELD:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const NO_INTERNET_FR_2 = "Aucun accès à Internet"
|
|||||||
const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
||||||
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
||||||
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
||||||
|
const MESSAGE_URL_VALIDATION_FR_3 = "vous allez recevoir un courriel de notre part"
|
||||||
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
||||||
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 WRONG_PHONE_NUMBER = "Veuillez renseigner vote numéro de téléphone"
|
const WRONG_PHONE_NUMBER = "Veuillez renseigner vote numéro de téléphone"
|
||||||
@@ -47,7 +48,7 @@ const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
|
|||||||
const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés"
|
const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés"
|
||||||
const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré"
|
const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré"
|
||||||
const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
|
const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
|
||||||
const MESSAGE_FILL_FIELD_FR_5 = "email vous sera envoyé pour vous"
|
const MESSAGE_FILL_FIELD_FR_5 = "demande de rendez-vous pour le"
|
||||||
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
|
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
|
||||||
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
|
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
|
||||||
const WELCOME_MESSAGE_FR_2 = "Chrome Connectez-vous"
|
const WELCOME_MESSAGE_FR_2 = "Chrome Connectez-vous"
|
||||||
@@ -100,7 +101,10 @@ class OCRChecker {
|
|||||||
try {
|
try {
|
||||||
let result = await findText(fileName)
|
let result = await findText(fileName)
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR) || result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
if (result.includes(MESSAGE_URL_VALIDATION_EN)
|
||||||
|
|| result.includes(MESSAGE_URL_VALIDATION_FR)
|
||||||
|
|| result.toLowerCase().includes(MESSAGE_URL_VALIDATION_FR_3)
|
||||||
|
|| result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.SUCCESS
|
return OCRResult.SUCCESS
|
||||||
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
@@ -121,7 +125,7 @@ class OCRChecker {
|
|||||||
} else if (result.includes(WRONG_PHONE_NUMBER)) {
|
} else if (result.includes(WRONG_PHONE_NUMBER)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.WRONG_PHONE_NUMBER
|
return OCRResult.WRONG_PHONE_NUMBER
|
||||||
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5) || result.includes(MESSAGE_FILL_FIELD_FR_6)) {
|
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.toLowerCase().includes(MESSAGE_FILL_FIELD_FR_5) || result.includes(MESSAGE_FILL_FIELD_FR_6)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.FILL_FIELD
|
return OCRResult.FILL_FIELD
|
||||||
} 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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user