diff --git a/clear_data.sh b/clear_data.sh index 735c885..e709659 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -6,4 +6,10 @@ adb -s J4AXB761H2322WJ shell am set-debug-app --persistent com.android.chrome adb -s J4AXB761H2322WJ shell am start -n com.android.chrome/com.google.android.apps.chrome.Main adb -s e30eb015 shell pm clear com.android.chrome adb -s e30eb015 shell am set-debug-app --persistent com.android.chrome -adb -s e30eb015 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s e30eb015 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main +adb -s 07f9c883 shell pm clear com.android.chrome +adb -s 07f9c883 shell am set-debug-app --persistent com.android.chrome +adb -s 07f9c883 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main +adb -s 76a3ac8d shell pm clear com.android.chrome +adb -s 76a3ac8d shell am set-debug-app --persistent com.android.chrome +adb -s 76a3ac8d shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 134a646..96a1a1d 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -4,9 +4,10 @@ const SolveCaptcha = require("./SolveCaptcha"); const ReserveResultPojo = require("../models/ReserveResultPojo"); const PublishType = require("../models/PublishType"); -const RDV_URL = "http://192.168.1.16:8000/test_appointment.html" -// const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; +// const RDV_URL = "http://192.168.1.16:8000/test_appointment.html" +const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; BLANK_URL = "about:blank" +const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; const COUNTRY_ID = "#phone_country" const PHONE_NUMBER = "#phone_number" @@ -18,7 +19,7 @@ const CGU_ID = "#cgu" const PROCESSING_ID = "#processing" const PASSPORT_ID = "#passport_id" -const TIME_OUT = 60 * 1000 * 10//10mins +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." @@ -72,7 +73,12 @@ class CommandorPage { this.page.on("response", (response) => { this.onResponse(response) }) - await this.page.goto(RDV_URL, {timeout: 90 * 1000}); + try { + await this.page.goto(RDV_URL, {timeout: 90 * 1000}); + }catch (e) { + console.log(e) + this.isTerminated = true + } //wait 10 mins // Close the device. @@ -190,10 +196,14 @@ class CommandorPage { this.captchaSolver = new SolveCaptcha(page); await this.captchaSolver.start((solution) => { console.log("solution is: " + solution); + if (solution !== ERROR_CAPTCHA_UNSOLVABLE){ page.evaluate((solution) => { document.getElementById("g-recaptcha-response").innerHTML = solution; }, solution) - this.clickValid(); + this.clickValid();} + else{ + this.isTerminated = true; + } }) } @@ -202,11 +212,13 @@ class CommandorPage { let captcha_url = "geo.captcha-delivery.com/captcha"; if (content.toString().includes(captcha_url)) { - this.checkAudioBtn(); + await this.checkAudioBtn(); console.log("we are blocked"); } else { if (currentPage.url() === RDV_URL) { await this.fillFields(this.page); + if (this.isFillingFields) + this.getErrors() } else { if (content.includes(MESSAGE_URL_VALIDATION_FR)) { console.log("successful"); @@ -219,14 +231,14 @@ class CommandorPage { } } - checkAudioBtn() { - let iframe = this.page.querySelector("iframe").contentFrame(); - let audioBtn = iframe.querySelector("#captcha__audio__button"); - if (audioBtn) { - console.log("audioBtn found") - } else { - console.log("audioBtn not found") - } + async checkAudioBtn() { + // let iframe = await this.page.locator("iframe").contentFrame; + // let audioBtn = iframe.locator("#captcha__audio__button"); + // if (audioBtn) { + // console.log("audioBtn found") + // } else { + // console.log("audioBtn not found") + // } } async onResponse(response) {