set to random store and try catch

This commit is contained in:
2022-09-16 23:29:12 +02:00
parent 47fecec58f
commit 726e4244dc
+33 -27
View File
@@ -192,17 +192,17 @@ class CommandorPage {
}
async chooseStore(page) {
try {
if (!page.isClosed()) {
await page.locator(PREFER_STORE).focus()
await delay(1000)
await page.click(PREFER_STORE);
await page.selectOption(PREFER_STORE, "faubourg");
}
} catch (e) {
console.log(e);
this.isTerminated = true;
}
// try {
// if (!page.isClosed()) {
// await page.locator(PREFER_STORE).focus()
// await delay(1000)
// await page.click(PREFER_STORE);
// await page.selectOption(PREFER_STORE, "faubourg");
// }
// } catch (e) {
// console.log(e);
// this.isTerminated = true;
// }
// await page.click(PREFER_STORE);
}
@@ -272,27 +272,33 @@ class CommandorPage {
}
async onPageLoad(currentPage) {
let content = await currentPage.content();
let captcha_url = "geo.captcha-delivery.com/captcha";
try {
if (content.toString().includes(captcha_url)) {
await this.checkAudioBtn();
beep(20)
console.log("发现datadome");
} else {
if (currentPage.url() === RDV_URL) {
await this.fillFields(this.page);
if (this.isFillingFields)
await this.getErrors()
let content = await currentPage.content();
let captcha_url = "geo.captcha-delivery.com/captcha";
if (content.toString().includes(captcha_url)) {
await this.checkAudioBtn();
beep(20)
console.log("发现datadome");
} else {
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
console.log("successful");
await this.push_message_to_queue(PublishType.SUCCESS);
if (currentPage.url() === RDV_URL) {
await this.fillFields(this.page);
if (this.isFillingFields)
await this.getErrors()
} else {
// try to get errors
await this.getErrors()
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
console.log("successful");
await this.push_message_to_queue(PublishType.SUCCESS);
} else {
// try to get errors
await this.getErrors()
}
}
}
} catch (e) {
console.log(e)
}
}