correction on the exceptions
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
const DeviceExcludeMode = {
|
||||
NINE: Symbol("NINE"),
|
||||
THREE: Symbol("THREE"),
|
||||
FOUR: Symbol("FOUR")
|
||||
}
|
||||
module.exports = DeviceExcludeMode
|
||||
@@ -8,7 +8,6 @@ const puppeteer = require('puppeteer');
|
||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||
const SlidingCaptchaSolver = require("./SlidingCaptchaSolver");
|
||||
const OCRChecker = require("./OCRChecker");
|
||||
const {main, elephant} = require("yarn/lib/cli");
|
||||
const {exec} = require("child_process");
|
||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
@@ -252,7 +251,7 @@ class CommandorPage {
|
||||
|
||||
async acceptCookies() {
|
||||
logWithDevice("will accept Cookies", this.device);
|
||||
if (this.browser.isConnected()) {
|
||||
if (this.browser.isConnected() && !this.page.isClosed()) {
|
||||
try {
|
||||
await this.page.evaluate(() => {
|
||||
let buttons = document.getElementsByTagName('button');
|
||||
@@ -277,10 +276,10 @@ class CommandorPage {
|
||||
if (this.browser.isConnected() && !this.isTerminated) {
|
||||
try {
|
||||
if (!this.isCountryChoosen) {
|
||||
await page.focus(COUNTRY_ID);
|
||||
await delay(getRandomWaitTime())
|
||||
await page.click(COUNTRY_ID);
|
||||
await delay(getRandomWaitTime())
|
||||
// await page.focus(COUNTRY_ID);
|
||||
// await delay(getRandomWaitTime())
|
||||
// await page.click(COUNTRY_ID);
|
||||
// await delay(getRandomWaitTime())
|
||||
await page.select(COUNTRY_ID, 'FR');
|
||||
await delay(getRandomWaitTime())
|
||||
this.isCountryChoosen = true;
|
||||
@@ -361,7 +360,7 @@ class CommandorPage {
|
||||
try {
|
||||
logWithDevice("input name called with this.browser.isConnected=" + this.browser.isConnected(), this.device)
|
||||
logWithDevice("input name called with this.isNameInput=" + this.isNameInput, this.device)
|
||||
if (this.browser.isConnected() && !this.isTerminated) {
|
||||
if (this.browser.isConnected() && !this.isTerminated && !this.page.isClosed()) {
|
||||
if (!this.isNameInput) {
|
||||
await page.focus(LAST_NAME);
|
||||
await delay(getRandomWaitTime());
|
||||
@@ -394,7 +393,8 @@ class CommandorPage {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
log(e);
|
||||
logWithDevice("exception while inputting name", this.device)
|
||||
console.log(e);
|
||||
this.isTerminated = true
|
||||
}
|
||||
}
|
||||
@@ -460,7 +460,7 @@ class CommandorPage {
|
||||
async checkCGU(page) {
|
||||
logWithDevice("checkCGU", this.device)
|
||||
try {
|
||||
if (this.browser.isConnected() && !this.isTerminated) {
|
||||
if (this.browser.isConnected() && !this.isTerminated && !this.page.isClosed()) {
|
||||
if (!this.cguChecked) {
|
||||
await page.focus(CGU_ID);
|
||||
await page.evaluate(() => {
|
||||
@@ -516,11 +516,11 @@ class CommandorPage {
|
||||
logWithDevice("fillFields called for contact: " + this.contact.mail, this.device)
|
||||
logWithDevice("this.isFillingFields: " + this.isFillingFields, this.device);
|
||||
logWithDevice("this.isTerminated: " + this.isTerminated, this.device);
|
||||
if (!this.isFillingFields && !this.isTerminated) {
|
||||
if (!this.isFillingFields && !this.isTerminated && !this.page.isClosed()) {
|
||||
this.isFillingFields = true;
|
||||
await this.chooseStore(page);
|
||||
await this.inputName(page);
|
||||
await this.chooseCountry(page);
|
||||
// await this.chooseCountry(page);
|
||||
await this.inputPhoneNumber(page)
|
||||
await this.fillEmail(page)
|
||||
await this.inputPassportId(page)
|
||||
@@ -528,13 +528,13 @@ class CommandorPage {
|
||||
let pageContent = await page.content()
|
||||
let hasCaptcha = pageContent.includes("g-recaptcha-response")
|
||||
if (hasCaptcha) {
|
||||
await this.resolveCaptcha(page)
|
||||
await delay(10 * 1000)
|
||||
this.isFillingFields = false
|
||||
await this.resolveCaptcha(page);
|
||||
await delay(getRandomWaitTime());
|
||||
this.isFillingFields = false;
|
||||
} else {
|
||||
this.isFillingFields = false
|
||||
await delay(2 * 1000)
|
||||
await delay(getRandomWaitTime())
|
||||
await this.clickValid();
|
||||
this.isFillingFields = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -544,7 +544,7 @@ class CommandorPage {
|
||||
await delay(getRandomWaitTime())
|
||||
try {
|
||||
if (!this.page.isClosed()) {
|
||||
if (!this.isTerminated) {
|
||||
if (!this.isTerminated && !this.page.isClosed()) {
|
||||
this.page.evaluate(() => {
|
||||
let element = document.getElementsByClassName("btn")[0];
|
||||
if (typeof element !== 'undefined')
|
||||
@@ -559,6 +559,7 @@ class CommandorPage {
|
||||
logWithDevice("will click on valid button", this.device);
|
||||
logWithDevice("isTerminated is " + this.isTerminated, this.device);
|
||||
if (!this.isTerminated) {
|
||||
if (!this.page.isClosed()) {
|
||||
let raw = await this.getRawAppointmentInfo(this.page)
|
||||
if (raw.email !== undefined) {
|
||||
this.contact.mail = raw.email
|
||||
@@ -583,7 +584,7 @@ class CommandorPage {
|
||||
await this.checkResultWithOcr();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
log(e);
|
||||
await this.checkResultWithOcr()
|
||||
@@ -865,13 +866,22 @@ class CommandorPage {
|
||||
let pages = await this.browser.pages();
|
||||
// let needPages = pages.filter(currentPage => currentPage.url() === RDV_URL)
|
||||
// this.page = needPages[0]
|
||||
try {
|
||||
pages.forEach((currentPage) => {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
this.page = currentPage;
|
||||
} else {
|
||||
try {
|
||||
currentPage.close()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
this.isTerminated = true;
|
||||
console.log(e)
|
||||
}
|
||||
logWithDevice("this.page.bringToFront();", this.device)
|
||||
|
||||
await this.page.bringToFront();
|
||||
@@ -890,13 +900,24 @@ class CommandorPage {
|
||||
logWithDevice("get current page", this.device)
|
||||
// let needPages = pages.filter(currentPage => currentPage.url() === RDV_URL)
|
||||
// this.page = needPages[0]
|
||||
try {
|
||||
pages.forEach((currentPage) => {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
this.page = currentPage;
|
||||
} else {
|
||||
try {
|
||||
if (!currentPage.isClosed()) {
|
||||
currentPage.close()
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
this.isTerminated = true
|
||||
console.log(e)
|
||||
}
|
||||
logWithDevice("this.page.bringToFront();", this.device)
|
||||
await this.page.bringToFront();
|
||||
// this.page = pages;
|
||||
|
||||
Reference in New Issue
Block a user