click on the checkbox
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@
|
||||
"node-schedule": "^2.1.0",
|
||||
"node-wget": "^0.4.3",
|
||||
"node-xlsx": "^0.21.0",
|
||||
"playwright": "1.25.2",
|
||||
"playwright": "^1.32.1",
|
||||
"read-ini-file": "^3.0.1",
|
||||
"winston": "^3.8.2",
|
||||
"yarn": "^1.22.19"
|
||||
|
||||
@@ -81,11 +81,11 @@ class CommandorPage {
|
||||
// Connect to the device.
|
||||
log("loadPage() called");
|
||||
// await this.device.shell('am force-stop com.android.chrome');
|
||||
const context = await this.device.launchBrowser();
|
||||
try {
|
||||
this.context = await this.device.launchBrowser();
|
||||
// await context.clearCookies()
|
||||
|
||||
// Use BrowserContext as usual.
|
||||
this.page = await context.newPage();
|
||||
this.page = await this.context.newPage();
|
||||
this.page.on("load", (loadedPage) => {
|
||||
this.onPageLoad(loadedPage)
|
||||
})
|
||||
@@ -93,6 +93,11 @@ class CommandorPage {
|
||||
this.page.on("response", (response) => {
|
||||
this.onResponse(response)
|
||||
})
|
||||
} catch (e) {
|
||||
log(e)
|
||||
this.isTerminated = true
|
||||
}
|
||||
|
||||
try {
|
||||
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});
|
||||
@@ -104,15 +109,9 @@ class CommandorPage {
|
||||
try {
|
||||
if (this.page.url().includes("google"))
|
||||
this.page.locator('button >> nth=3').click()
|
||||
// this.page.locator('button:has-text("Tout accepter")').click()
|
||||
} catch (e) {
|
||||
log(e)
|
||||
}
|
||||
// try {
|
||||
// this.page.locator('button:has-text("Accept all")').click()
|
||||
// } catch (e) {
|
||||
// log(e)
|
||||
// }
|
||||
try {
|
||||
this.page.locator(':nth-match(:text("rendezvousparis"), 1)').click()
|
||||
} catch (e) {
|
||||
@@ -124,12 +123,17 @@ class CommandorPage {
|
||||
const intervalTask = setInterval(() => {
|
||||
if (this.isTerminated) {
|
||||
log(this.device.model() + ":request terminated, will close device");
|
||||
context.close();
|
||||
this.context.close();
|
||||
// this.page.close()
|
||||
this.device.close()
|
||||
// this.device.close()
|
||||
clearInterval(intervalTask)
|
||||
cancel()
|
||||
return context
|
||||
return this.context
|
||||
} else {
|
||||
if (this.page.url() === RDV_URL) {
|
||||
if (!this.isFillingFields)
|
||||
this.fillFields(this.page);
|
||||
}
|
||||
}
|
||||
}, 10 * 1000)//interval of 10 seconds
|
||||
|
||||
@@ -316,6 +320,8 @@ class CommandorPage {
|
||||
let pageContent = await page.content()
|
||||
let hasCaptcha = pageContent.includes("g-recaptcha-response")
|
||||
if (hasCaptcha) {
|
||||
await this.clickCheckbox()
|
||||
await delay(1000)
|
||||
this.captchaSolver = new SolveCaptcha(page);
|
||||
await this.captchaSolver.start((solution) => {
|
||||
log("solution is: " + solution);
|
||||
@@ -370,8 +376,8 @@ class CommandorPage {
|
||||
} else {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
await this.fillFields(this.page);
|
||||
if (this.isFillingFields)
|
||||
await this.getErrors()
|
||||
// if (this.isFillingFields)
|
||||
// await this.getErrors()
|
||||
} else {
|
||||
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
||||
log("successful");
|
||||
@@ -462,6 +468,15 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
async handleError(errorContent) {
|
||||
log("handle error:" + errorContent);
|
||||
if (errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE) || errorContent.includes(DOUBLE_REQUEST_ERROR_MESSAGE_FR)) {
|
||||
|
||||
Reference in New Issue
Block a user