works on xiaomi
This commit is contained in:
@@ -90,9 +90,10 @@ class CommandorPage {
|
||||
// Connect to the device.
|
||||
log("loadPage() called");
|
||||
try {
|
||||
this.browser = await puppeteer.connect({browserWSEndpoint: 'ws://127.0.0.1:9002/devtools/browser',})
|
||||
// await context.clearCookies()
|
||||
// Use BrowserContext as usual.
|
||||
this.browser = await puppeteer.connect({
|
||||
browserWSEndpoint: 'ws://127.0.0.1:9002/devtools/browser',
|
||||
headless: false, defaultViewport: null
|
||||
})
|
||||
this.page = await this.browser.newPage();
|
||||
|
||||
this.page.on("load", (loadedPage) => {
|
||||
@@ -126,9 +127,16 @@ class CommandorPage {
|
||||
}
|
||||
try {
|
||||
// let element = await this.page.$(':nth-match(:text("rendezvousparis"), 1)')
|
||||
await this.page.$eval(':nth-match(:text("rendezvousparis"), 1)', el => {
|
||||
el.click()
|
||||
});
|
||||
// let element = await this.page.$(':nth-match(:text("rendezvousparis"), 1)')
|
||||
const [button] = await this.page.$x("//a[contains(., 'rendezvousparis')]");
|
||||
console.log("button is " + button)
|
||||
if (button) {
|
||||
console.log("will click on the button")
|
||||
await button.click();
|
||||
}
|
||||
// await this.page.$eval(':nth-match(:text("rendezvousparis"), 1)', el => {
|
||||
// el.click()
|
||||
// });
|
||||
} catch (e) {
|
||||
log(e)
|
||||
if (!this.page.url().includes(RDV_URL)) {
|
||||
@@ -202,7 +210,7 @@ class CommandorPage {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.isPhoneInput) {
|
||||
await page.focus(PHONE_NUMBER);
|
||||
await page.keyboard.type("+330" + this.contact.phoneNumber);
|
||||
await page.keyboard.type("" + this.contact.phoneNumber);
|
||||
this.isPhoneInput = true;
|
||||
}
|
||||
}
|
||||
@@ -254,10 +262,20 @@ class CommandorPage {
|
||||
if (!page.isClosed()) {
|
||||
if (!this.cguChecked) {
|
||||
await page.focus(CGU_ID);
|
||||
await page.click(CGU_ID);
|
||||
await page.evaluate(() => {
|
||||
if (!document.querySelector("#cgu").checked) {
|
||||
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.click(PROCESSING_ID)
|
||||
await page.evaluate(() => {
|
||||
if (!document.querySelector("#processing").checked) {
|
||||
document.querySelector("#processing").checked = true
|
||||
}
|
||||
});
|
||||
this.cguChecked = true;
|
||||
}
|
||||
}
|
||||
@@ -318,11 +336,10 @@ class CommandorPage {
|
||||
if (!this.page.isClosed()) {
|
||||
try {
|
||||
// remove debug flag
|
||||
await this.removeDebugFlag()
|
||||
const validElement = await page.$('.btn');
|
||||
// this.page.evaluate(() => {
|
||||
// document.getElementsByClassName("btn")[0].click();
|
||||
// })
|
||||
// const validElement = await page.$('.btn');
|
||||
this.page.evaluate(() => {
|
||||
document.getElementsByClassName("btn")[0].click();
|
||||
})
|
||||
} catch (e) {
|
||||
log(e)
|
||||
}
|
||||
@@ -513,7 +530,7 @@ class CommandorPage {
|
||||
|
||||
async onResponse(response) {
|
||||
let rex = new RegExp(REGEX_RDV_URL)
|
||||
log("onResponse with url:" + response.url())
|
||||
// log("onResponse with url:" + response.url())
|
||||
// log("onResponse with url:" + response.body())
|
||||
if (rex.test(response.url())) {
|
||||
log("rdv url found:" + response.url())
|
||||
@@ -574,12 +591,12 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async clickCheckbox() {
|
||||
try {
|
||||
// let errorItem = await this.page.click("#recaptcha-anchor > div.recaptcha-checkbox-border")
|
||||
await this.page.frameLocator('[title="reCAPTCHA"]').getByRole('checkbox', {name: 'I\'m not a robot'}).click();
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
// try {
|
||||
// // let errorItem = await this.page.click("#recaptcha-anchor > div.recaptcha-checkbox-border")
|
||||
// await this.page.$('[title="reCAPTCHA"]').getByRole('checkbox', {name: 'I\'m not a robot'}).click();
|
||||
// } catch (e) {
|
||||
// log(e);
|
||||
// }
|
||||
}
|
||||
|
||||
async handleError(errorContent) {
|
||||
|
||||
Reference in New Issue
Block a user