From 2017e8b09961a7dc28972e903f584460be26a0b0 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 9 Sep 2022 14:53:09 +0200 Subject: [PATCH] correction on handleErrors --- clear_data.sh | 6 +++++- src/workers/CommandorPage.js | 23 ++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/clear_data.sh b/clear_data.sh index e709659..2733813 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -12,4 +12,8 @@ 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 +adb -s 76a3ac8d shell am start -n com.android.chrome/com.google.android.apps.chrome.Main +#xiao mi +adb -s 47e7e36b shell pm clear com.android.chrome +adb -s 47e7e36b shell am set-debug-app --persistent com.android.chrome +adb -s 47e7e36b 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 6163b82..a3e3995 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -200,15 +200,12 @@ class CommandorPage { document.getElementById("g-recaptcha-response").innerHTML = solution; }, solution) this.clickValid(); + } catch + (e) { + console.log(e) + this.isTerminated = true; } - catch - (e) - { - console.log(e) - this.isTerminated = true; - } - } - else{ + } else { this.isTerminated = true; } }) @@ -225,14 +222,14 @@ class CommandorPage { if (currentPage.url() === RDV_URL) { await this.fillFields(this.page); if (this.isFillingFields) - this.getErrors() + await this.getErrors() } else { if (content.includes(MESSAGE_URL_VALIDATION_FR)) { console.log("successful"); await this.push_message_to_queue(PublishType.SUCCESS); } else { // try to get errors - this.getErrors() + await this.getErrors() } } } @@ -286,14 +283,14 @@ class CommandorPage { } - getErrors() { + async getErrors() { if (this.page.url() === BLANK_URL) { this.isTerminated = true; } else { try { - let errorItem = this.page.querySelector("div.alert"); + let errorItem = this.page.locator("div.alert"); if (errorItem) { - let errorContent = errorItem.innerHTML; + let errorContent = await errorItem.innerHTML(); console.log("error:" + errorContent); this.handleError(errorContent); }