This commit is contained in:
2022-12-09 14:11:00 +01:00
parent fde8eb294e
commit d50225eb27
+40 -23
View File
@@ -69,6 +69,10 @@ class CommandorPage {
this.audioAnalyse = audioAnalyse;
this.alertBeep = alertBeep;
this.cguChecked = false;
this.isNameInput = false;
this.isEmailFilled = false;
this.isCountryChoosen = false;
this.isPhoneInput = false;
}
@@ -90,7 +94,6 @@ class CommandorPage {
})
try {
await this.page.goto("https://www.google.com/search?q=hemes+appointment", {timeout: 90 * 1000});
// this.page.locator('h3:has-text("Online Appointment")').click()
// await this.page.goto(RDV_URL, {timeout: 90 * 1000});
} catch (e) {
log(e)
@@ -137,12 +140,15 @@ class CommandorPage {
async chooseCountry(page) {
if (!page.isClosed()) {
try {
await page.locator(COUNTRY_ID).focus();
await delay(getRandomWaitTime())
await page.click(COUNTRY_ID);
await delay(getRandomWaitTime())
await page.selectOption(COUNTRY_ID, 'FR');
await delay(getRandomWaitTime())
if (!this.isCountryChoosen) {
await page.locator(COUNTRY_ID).focus();
await delay(getRandomWaitTime())
await page.click(COUNTRY_ID);
await delay(getRandomWaitTime())
await page.selectOption(COUNTRY_ID, 'FR');
await delay(getRandomWaitTime())
this.isCountryChoosen = true;
}
} catch (e) {
log(e);
this.isTerminated = true;
@@ -153,9 +159,12 @@ class CommandorPage {
async fillEmail(page) {
try {
if (!page.isClosed()) {
await page.locator(EMAIL_ID).focus();
await delay(getRandomWaitTime())
await page.locator(EMAIL_ID).fill(this.contact.mail);
if (!this.isEmailFilled) {
await page.locator(EMAIL_ID).focus();
await delay(getRandomWaitTime())
await page.locator(EMAIL_ID).fill(this.contact.mail);
this.isEmailFilled = true;
}
}
} catch (e) {
log(e)
@@ -165,8 +174,11 @@ class CommandorPage {
async inputPhoneNumber(page) {
try {
if (!page.isClosed()) {
await page.locator(PHONE_NUMBER).focus()
await page.locator(PHONE_NUMBER).fill("0" + this.contact.phoneNumber)
if (!this.isPhoneInput) {
await page.locator(PHONE_NUMBER).focus();
await page.locator(PHONE_NUMBER).fill("0" + this.contact.phoneNumber);
this.isPhoneInput = true;
}
}
} catch (e) {
log(e);
@@ -178,12 +190,15 @@ class CommandorPage {
async inputName(page) {
try {
if (!page.isClosed()) {
await page.locator(LAST_NAME).focus()
await delay(getRandomWaitTime())
await page.locator(LAST_NAME).fill(this.contact.lastName)
await page.locator(FIRST_NAME).focus()
await delay(getRandomWaitTime())
await page.locator(FIRST_NAME).fill(this.contact.firstName)
if (!this.isNameInput) {
await page.locator(LAST_NAME).focus()
await delay(getRandomWaitTime())
await page.locator(LAST_NAME).fill(this.contact.lastName)
await page.locator(FIRST_NAME).focus()
await delay(getRandomWaitTime())
await page.locator(FIRST_NAME).fill(this.contact.firstName)
this.isNameInput = true
}
}
} catch (e) {
log(e);
@@ -194,10 +209,12 @@ class CommandorPage {
async inputPassportId(page) {
try {
if (!page.isClosed()) {
await page.locator(PASSPORT_ID).focus()
await delay(getRandomWaitTime())
await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString())
if (!this.isPasspordInput) {
await page.locator(PASSPORT_ID).focus();
await delay(getRandomWaitTime());
await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString());
this.isPasspordInput = true;
}
}
} catch (e) {
log(e);
@@ -253,7 +270,7 @@ class CommandorPage {
await this.chooseCountry(page);
await this.inputPhoneNumber(page)
await this.fillEmail(page)
await this.inputPhoneNumber(page)
// await this.inputPhoneNumber(page)
await this.inputPassportId(page)
await this.checkCGU(page)
await this.resolveCaptcha(page)