not work on xiaomi
This commit is contained in:
@@ -3,13 +3,16 @@ const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||
const BlackListContactPojo = require("../models/BlackListContactPojo");
|
||||
const appointmentLogger = require("../utiles/LoggerUtils")
|
||||
const PublishType = require("../models/PublishType");
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
const {
|
||||
shell
|
||||
} = require('electron')
|
||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||
const SlidingCaptchaSolver = require("./SlidingCaptchaSolver");
|
||||
// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
const {de} = 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"
|
||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||
|
||||
@@ -83,15 +86,15 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
|
||||
async loadPage() {
|
||||
async loadPage(port) {
|
||||
// Connect to the device.
|
||||
log("loadPage() called");
|
||||
// await this.device.shell('am force-stop com.android.chrome');
|
||||
try {
|
||||
this.context = await this.device.launchBrowser();
|
||||
this.browser = await puppeteer.connect({browserWSEndpoint: 'ws://127.0.0.1:9002/devtools/browser',})
|
||||
// await context.clearCookies()
|
||||
// Use BrowserContext as usual.
|
||||
this.page = await this.context.newPage();
|
||||
this.page = await this.browser.newPage();
|
||||
|
||||
this.page.on("load", (loadedPage) => {
|
||||
this.onPageLoad(loadedPage)
|
||||
})
|
||||
@@ -100,26 +103,31 @@ class CommandorPage {
|
||||
this.onResponse(response)
|
||||
})
|
||||
} catch (e) {
|
||||
log(e)
|
||||
console.log(e)
|
||||
this.isTerminated = true
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("will open google")
|
||||
const item = searchTexts[Math.floor(Math.random() * searchTexts.length)];
|
||||
await this.page.goto("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 90 * 1000});
|
||||
// await this.page.goto(RDV_URL, {timeout: 90 * 1000});
|
||||
} catch (e) {
|
||||
log(e)
|
||||
this.isTerminated = true
|
||||
}
|
||||
try {
|
||||
if (this.page.url().includes("google"))
|
||||
this.page.locator('button >> nth=3').click()
|
||||
if (this.page.url().includes("google")) {
|
||||
this.page.focus('button >> nth=3')
|
||||
this.page.click()
|
||||
}
|
||||
} catch (e) {
|
||||
log(e)
|
||||
}
|
||||
try {
|
||||
// await this.setUpCookies()
|
||||
this.page.locator(':nth-match(:text("rendezvousparis"), 1)').click()
|
||||
await this.page.focus(':nth-match(:text("rendezvousparis"), 1)')
|
||||
await this.page.click()
|
||||
} catch (e) {
|
||||
log(e)
|
||||
if (!this.page.url().includes(RDV_URL)) {
|
||||
@@ -131,13 +139,13 @@ class CommandorPage {
|
||||
const intervalTask = setInterval(() => {
|
||||
if (this.isTerminated) {
|
||||
log(this.device.model() + ":request terminated, will close device");
|
||||
if (this.context !== undefined)
|
||||
this.context.close();
|
||||
if (this.browser !== undefined)
|
||||
this.browser.close();
|
||||
// this.page.close()
|
||||
// this.device.close()
|
||||
clearInterval(intervalTask)
|
||||
cancel()
|
||||
return this.context
|
||||
return this.browser
|
||||
} else {
|
||||
if (this.page.url() === RDV_URL) {
|
||||
if (!this.isFillingFields)
|
||||
@@ -158,11 +166,11 @@ class CommandorPage {
|
||||
if (!page.isClosed()) {
|
||||
try {
|
||||
if (!this.isCountryChoosen) {
|
||||
await page.locator(COUNTRY_ID).focus();
|
||||
await page.focus(COUNTRY_ID);
|
||||
await delay(getRandomWaitTime())
|
||||
await page.click(COUNTRY_ID);
|
||||
await delay(getRandomWaitTime())
|
||||
await page.selectOption(COUNTRY_ID, 'FR');
|
||||
await page.select(COUNTRY_ID, 'FR');
|
||||
await delay(getRandomWaitTime())
|
||||
this.isCountryChoosen = true;
|
||||
}
|
||||
@@ -177,9 +185,9 @@ class CommandorPage {
|
||||
try {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.isEmailFilled) {
|
||||
await page.locator(EMAIL_ID).focus();
|
||||
await page.focus(EMAIL_ID);
|
||||
await delay(getRandomWaitTime())
|
||||
await page.locator(EMAIL_ID).fill(this.contact.mail);
|
||||
await page.keyboard.type(this.contact.mail);
|
||||
this.isEmailFilled = true;
|
||||
}
|
||||
}
|
||||
@@ -192,8 +200,8 @@ class CommandorPage {
|
||||
try {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.isPhoneInput) {
|
||||
await page.locator(PHONE_NUMBER).focus();
|
||||
await page.locator(PHONE_NUMBER).fill("+330" + this.contact.phoneNumber);
|
||||
await page.focus(PHONE_NUMBER);
|
||||
await page.keyboard.type("+330" + this.contact.phoneNumber);
|
||||
this.isPhoneInput = true;
|
||||
}
|
||||
}
|
||||
@@ -208,13 +216,13 @@ class CommandorPage {
|
||||
try {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.isNameInput) {
|
||||
await page.locator(LAST_NAME).focus()
|
||||
await delay(getRandomWaitTime())
|
||||
await page.locator(LAST_NAME).fill(this.contact.lastName)
|
||||
await page.locator(FIRST_NAME).focus()
|
||||
await delay(getRandomWaitTime())
|
||||
await page.locator(FIRST_NAME).fill(this.contact.firstName)
|
||||
this.isNameInput = true
|
||||
await page.focus(LAST_NAME);
|
||||
await delay(getRandomWaitTime());
|
||||
await page.keyboard.type(this.contact.lastName);
|
||||
await page.focus(FIRST_NAME);
|
||||
await delay(getRandomWaitTime());
|
||||
await page.keyboard.type(this.contact.firstName);
|
||||
this.isNameInput = true;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -227,9 +235,9 @@ class CommandorPage {
|
||||
try {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.isPasspordInput) {
|
||||
await page.locator(PASSPORT_ID).focus();
|
||||
await page.focus(PASSPORT_ID);
|
||||
await delay(getRandomWaitTime());
|
||||
await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString());
|
||||
await page.keyboard.type(this.contact.passportNumber.toString())
|
||||
this.isPasspordInput = true;
|
||||
}
|
||||
}
|
||||
@@ -244,11 +252,11 @@ class CommandorPage {
|
||||
try {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.cguChecked) {
|
||||
await page.locator(CGU_ID).focus()
|
||||
await page.locator(CGU_ID).click()
|
||||
await delay(getRandomWaitTime())
|
||||
await page.locator(PROCESSING_ID).focus()
|
||||
await page.locator(PROCESSING_ID).click()
|
||||
await page.focus(CGU_ID);
|
||||
await page.click(CGU_ID);
|
||||
await delay(getRandomWaitTime());
|
||||
await page.focus(PROCESSING_ID);
|
||||
await page.click(PROCESSING_ID)
|
||||
this.cguChecked = true;
|
||||
}
|
||||
}
|
||||
@@ -262,12 +270,12 @@ class CommandorPage {
|
||||
try {
|
||||
if (!page.isClosed()) {
|
||||
if (this.selectedStore !== "random") {
|
||||
await page.locator(PREFER_STORE).focus()
|
||||
page.focus(PREFER_STORE);
|
||||
await delay(1000)
|
||||
await page.click(PREFER_STORE);
|
||||
page.click(PREFER_STORE);
|
||||
let stores = this.selectedStore.split(":")
|
||||
this.choosedStore = stores[Math.floor(Math.random() * stores.length)]
|
||||
await page.selectOption(PREFER_STORE, this.choosedStore);
|
||||
await page.select(PREFER_STORE, this.choosedStore);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -326,7 +334,8 @@ class CommandorPage {
|
||||
|
||||
async resolveCaptcha(page) {
|
||||
if (RDV_URL.includes("192")) {
|
||||
await this.push_message_to_queue(PublishType.SUCCESS)
|
||||
// await this.push_message_to_queue(PublishType.SUCCESS)
|
||||
await delay(100000)
|
||||
return
|
||||
}
|
||||
//check whether there is captcha
|
||||
@@ -552,11 +561,11 @@ class CommandorPage {
|
||||
this.isTerminated = true;
|
||||
} else {
|
||||
try {
|
||||
let errorItem = this.page.locator("div.alert");
|
||||
if (errorItem) {
|
||||
let errorContent = await errorItem.innerHTML();
|
||||
await this.handleError(errorContent);
|
||||
}
|
||||
// let errorItem = this.page.locator("div.alert");
|
||||
// if (errorItem) {
|
||||
// let errorContent = await errorItem.innerHTML();
|
||||
// await this.handleError(errorContent);
|
||||
// }
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user