support new version
This commit is contained in:
@@ -11,6 +11,7 @@ const {exec} = require("child_process");
|
||||
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
||||
const RequestDataPojo = require("../models/RequestDataPojo");
|
||||
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 = "https://rendezvousparis.hermes.com/client/register";
|
||||
const BLANK_URL = "about:blank"
|
||||
@@ -50,6 +51,12 @@ function getRandom() {
|
||||
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() {
|
||||
return getRandom() * 1000
|
||||
}
|
||||
@@ -401,12 +408,12 @@ class CommandorPage {
|
||||
// await page.focus(LAST_NAME);
|
||||
await delay(getRandomWaitTime());
|
||||
console.log("will clear surname field");
|
||||
await page.evaluate(() => {
|
||||
let field = document.getElementById("surname");
|
||||
if (field) {
|
||||
field.value = ""
|
||||
}
|
||||
})
|
||||
// await page.evaluate(() => {
|
||||
// let field = document.getElementById("surname");
|
||||
// if (field) {
|
||||
// field.value = ""
|
||||
// }
|
||||
// })
|
||||
await delay(1000);
|
||||
// await page.keyboard.type(this.contact.lastName);
|
||||
await page.evaluate((lastName) => {
|
||||
@@ -422,7 +429,6 @@ class CommandorPage {
|
||||
let field = document.getElementById("name");
|
||||
if (field) {
|
||||
field.value = firstName;
|
||||
// field.value = ""
|
||||
}
|
||||
}, this.contact.firstName)
|
||||
// await page.keyboard.type(this.contact.firstName);
|
||||
@@ -505,10 +511,8 @@ class CommandorPage {
|
||||
document.querySelector("#cgu").checked = true
|
||||
}
|
||||
});
|
||||
// await page.click(CGU_ID);
|
||||
await delay(getRandomWaitTime());
|
||||
await page.focus(PROCESSING_ID);
|
||||
// await page.click(PROCESSING_ID)
|
||||
await page.evaluate(() => {
|
||||
if (!document.querySelector("#processing").checked) {
|
||||
document.querySelector("#processing").checked = true
|
||||
@@ -581,8 +585,12 @@ class CommandorPage {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async clickValid() {
|
||||
logWithDevice("clickValid() called.", this.device);
|
||||
let _id_to_click = getRandomId()
|
||||
await this.page.click(_id_to_click)
|
||||
|
||||
await delay(getRandomWaitTime())
|
||||
this.isFillingFields = false
|
||||
try {
|
||||
@@ -612,7 +620,7 @@ class CommandorPage {
|
||||
this.contact.firstName = raw.firstName
|
||||
}
|
||||
await this.page.evaluate(() => {
|
||||
document.getElementsByClassName("btn")[0].click();
|
||||
document.getElementsByTagName("button")[1].click();
|
||||
})
|
||||
if (this.firstStart) {
|
||||
this.disconnectBrowser();
|
||||
@@ -889,18 +897,20 @@ class CommandorPage {
|
||||
this.isTerminated = true;
|
||||
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()
|
||||
}
|
||||
})
|
||||
this.isAlreadyRefresh = true;
|
||||
await this.generateRandomActions()
|
||||
// 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()
|
||||
// }
|
||||
// })
|
||||
// await delay(5 * 1000)
|
||||
break;
|
||||
case OCRResult.FILL_FIELD:
|
||||
|
||||
Reference in New Issue
Block a user