use flag
This commit is contained in:
@@ -69,6 +69,10 @@ class CommandorPage {
|
|||||||
this.audioAnalyse = audioAnalyse;
|
this.audioAnalyse = audioAnalyse;
|
||||||
this.alertBeep = alertBeep;
|
this.alertBeep = alertBeep;
|
||||||
this.cguChecked = false;
|
this.cguChecked = false;
|
||||||
|
this.isNameInput = false;
|
||||||
|
this.isEmailFilled = false;
|
||||||
|
this.isCountryChoosen = false;
|
||||||
|
this.isPhoneInput = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -90,7 +94,6 @@ class CommandorPage {
|
|||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
await this.page.goto("https://www.google.com/search?q=hemes+appointment", {timeout: 90 * 1000});
|
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});
|
// await this.page.goto(RDV_URL, {timeout: 90 * 1000});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e)
|
log(e)
|
||||||
@@ -137,12 +140,15 @@ class CommandorPage {
|
|||||||
async chooseCountry(page) {
|
async chooseCountry(page) {
|
||||||
if (!page.isClosed()) {
|
if (!page.isClosed()) {
|
||||||
try {
|
try {
|
||||||
await page.locator(COUNTRY_ID).focus();
|
if (!this.isCountryChoosen) {
|
||||||
await delay(getRandomWaitTime())
|
await page.locator(COUNTRY_ID).focus();
|
||||||
await page.click(COUNTRY_ID);
|
await delay(getRandomWaitTime())
|
||||||
await delay(getRandomWaitTime())
|
await page.click(COUNTRY_ID);
|
||||||
await page.selectOption(COUNTRY_ID, 'FR');
|
await delay(getRandomWaitTime())
|
||||||
await delay(getRandomWaitTime())
|
await page.selectOption(COUNTRY_ID, 'FR');
|
||||||
|
await delay(getRandomWaitTime())
|
||||||
|
this.isCountryChoosen = true;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
@@ -153,9 +159,12 @@ class CommandorPage {
|
|||||||
async fillEmail(page) {
|
async fillEmail(page) {
|
||||||
try {
|
try {
|
||||||
if (!page.isClosed()) {
|
if (!page.isClosed()) {
|
||||||
await page.locator(EMAIL_ID).focus();
|
if (!this.isEmailFilled) {
|
||||||
await delay(getRandomWaitTime())
|
await page.locator(EMAIL_ID).focus();
|
||||||
await page.locator(EMAIL_ID).fill(this.contact.mail);
|
await delay(getRandomWaitTime())
|
||||||
|
await page.locator(EMAIL_ID).fill(this.contact.mail);
|
||||||
|
this.isEmailFilled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e)
|
log(e)
|
||||||
@@ -165,8 +174,11 @@ class CommandorPage {
|
|||||||
async inputPhoneNumber(page) {
|
async inputPhoneNumber(page) {
|
||||||
try {
|
try {
|
||||||
if (!page.isClosed()) {
|
if (!page.isClosed()) {
|
||||||
await page.locator(PHONE_NUMBER).focus()
|
if (!this.isPhoneInput) {
|
||||||
await page.locator(PHONE_NUMBER).fill("0" + this.contact.phoneNumber)
|
await page.locator(PHONE_NUMBER).focus();
|
||||||
|
await page.locator(PHONE_NUMBER).fill("0" + this.contact.phoneNumber);
|
||||||
|
this.isPhoneInput = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
@@ -178,12 +190,15 @@ class CommandorPage {
|
|||||||
async inputName(page) {
|
async inputName(page) {
|
||||||
try {
|
try {
|
||||||
if (!page.isClosed()) {
|
if (!page.isClosed()) {
|
||||||
await page.locator(LAST_NAME).focus()
|
if (!this.isNameInput) {
|
||||||
await delay(getRandomWaitTime())
|
await page.locator(LAST_NAME).focus()
|
||||||
await page.locator(LAST_NAME).fill(this.contact.lastName)
|
await delay(getRandomWaitTime())
|
||||||
await page.locator(FIRST_NAME).focus()
|
await page.locator(LAST_NAME).fill(this.contact.lastName)
|
||||||
await delay(getRandomWaitTime())
|
await page.locator(FIRST_NAME).focus()
|
||||||
await page.locator(FIRST_NAME).fill(this.contact.firstName)
|
await delay(getRandomWaitTime())
|
||||||
|
await page.locator(FIRST_NAME).fill(this.contact.firstName)
|
||||||
|
this.isNameInput = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
@@ -194,10 +209,12 @@ class CommandorPage {
|
|||||||
async inputPassportId(page) {
|
async inputPassportId(page) {
|
||||||
try {
|
try {
|
||||||
if (!page.isClosed()) {
|
if (!page.isClosed()) {
|
||||||
|
if (!this.isPasspordInput) {
|
||||||
await page.locator(PASSPORT_ID).focus()
|
await page.locator(PASSPORT_ID).focus();
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime());
|
||||||
await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString())
|
await page.locator(PASSPORT_ID).fill(this.contact.passportNumber.toString());
|
||||||
|
this.isPasspordInput = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
@@ -253,7 +270,7 @@ class CommandorPage {
|
|||||||
await this.chooseCountry(page);
|
await this.chooseCountry(page);
|
||||||
await this.inputPhoneNumber(page)
|
await this.inputPhoneNumber(page)
|
||||||
await this.fillEmail(page)
|
await this.fillEmail(page)
|
||||||
await this.inputPhoneNumber(page)
|
// await this.inputPhoneNumber(page)
|
||||||
await this.inputPassportId(page)
|
await this.inputPassportId(page)
|
||||||
await this.checkCGU(page)
|
await this.checkCGU(page)
|
||||||
await this.resolveCaptcha(page)
|
await this.resolveCaptcha(page)
|
||||||
|
|||||||
Reference in New Issue
Block a user