diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 51182d2..172982a 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -21,11 +21,10 @@ const FIRST_NAME = "#name" const CGU_ID = "#cgu" const PROCESSING_ID = "#processing" const PASSPORT_ID = "#passport_id" +const CAPTCHA_CONTAINER = "#captcha-container"; const TIME_OUT = 60 * 1000 * 4//4 mins -const CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been registered" -const CONFIRMED_MESSAGE_FR = "Votre demande de rendez-vous Maroquinerie a bien été enregistrée et nous vous en remercions." const EMPTY_RESPONSE_ERROR = "ERR_EMPTY_RESPONSE" const MESSAGE_URL_VALIDATION_FR = "Nous avons envoyé un lien par e-mail." const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email" @@ -89,7 +88,10 @@ class CommandorPage { this.onResponse(response) }) try { - await this.page.goto(RDV_URL, {timeout: 90 * 1000}); + await this.page.goto("https://www.google.com/search?q=hemes+rdv", {timeout: 90 * 1000}); + this.page.locator(':nth-match(:text("Online Appointment"), 1)').click() + // this.page.locator('h3:has-text("Online Appointment")').click() + // await this.page.goto(RDV_URL, {timeout: 90 * 1000}); } catch (e) { log(e) this.isTerminated = true @@ -293,6 +295,14 @@ class CommandorPage { }) } + async isBlocked() { + let iframeHandler = await this.page.frameLocator("body > iframe"); + let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER) + let html = await captcha_container.innerHTML() + console.log("audio_tag: " + html); + return html.includes("You have been blocked") + } + async onPageLoad(currentPage) { try { let content = await currentPage.content(); @@ -332,8 +342,9 @@ class CommandorPage { } async checkAudioBtn() { - let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button"); - if (audioBtn) { + let isBlocked = this.isBlocked() + if (!isBlocked) { + let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button"); log("audioBtn found") audioBtn.click() let captchaSolver = new GeoCaptchaSolver(this.page, this.device, this.isTerminated)