diff --git a/commandor_page.py b/commandor_page.py index 11ce131..30d6ab4 100644 --- a/commandor_page.py +++ b/commandor_page.py @@ -24,17 +24,17 @@ MESSAGE_FIELD_CLASS = ".message" CONFIRMED_MESSAGE = "Your request for a Leather Goods appointment has been registered" -def get_random_wait_time()-> float: - wait_time = random.randint(0,10)/10.0 * 2 + +def get_random_wait_time() -> float: + wait_time = random.randint(0, 10) / 10.0 * 5 return wait_time + class CommandorPage: def __init__(self): self.otp_value = None self.logger = logging.getLogger("CommandorPage") - - def _run(self, e: threading.Event, proxy, contact: ContactPojo, on_ready_for_otp, on_success): self.contact = contact self.on_success_listener = on_success @@ -59,21 +59,15 @@ class CommandorPage: "username": proxy_username, "password": params.PROXY_PASSWORD } - + self._setName(contact.last_name, contact.first_name) self._setPhoneCountryAndStore() - time.sleep(get_random_wait_time()) self.page.mouse.wheel(0, 50) self._setPhoneNumber(contact.phone) - time.sleep(get_random_wait_time()) - self._setName(contact.last_name, contact.first_name) - time.sleep(get_random_wait_time()) self._set_email(contact.mail) - time.sleep(get_random_wait_time()) self.setIdNumber(contact.passport) - self.page.mouse.wheel(0, random.randint(200,600)) + # self._checkCgu() # wait for sms_code field - self.page.mouse.wheel(0, random.randint(400,500)) self.clickOnValidBtn() # self.page.goto("file:///Users/lpan/Downloads/input_otp.html") otp_input = self.page.locator(OTP_FIELD_ID) @@ -137,10 +131,12 @@ class CommandorPage: document.getElementById("phone_country").value = \"FR\" }""") def _setPhoneNumber(self, phoneNumber): + time.sleep(get_random_wait_time()) self.page.evaluate("""(phoneNumber)=>document.getElementById("phone_number").value =phoneNumber""", phoneNumber) def _setName(self, lastName, firstName): + time.sleep(get_random_wait_time()) self.page.evaluate("""(name)=> { document.getElementById("surname").focus(); document.getElementById("surname").value = name.lastName; @@ -153,16 +149,19 @@ class CommandorPage: print(items.inner_html()) def _set_email(self, email): + time.sleep(get_random_wait_time()) self.page.evaluate("""(email)=>{ document.getElementById("email").focus(); document.getElementById("email").value = email;}""", email) def setIdNumber(self, id): + time.sleep(get_random_wait_time()) self.page.evaluate(""" (id) =>{ document.getElementById("passport_id").focus(); document.getElementById("passport_id").value = id}""", id) def _checkCgu(self): + self.page.mouse.wheel(0, random.randint(200, 600)) self.page.evaluate(""" document.getElementById("cgu").focus(); document.getElementById("cgu").checked = true; @@ -170,6 +169,7 @@ class CommandorPage: document.getElementById("processing").checked = true""") def clickOnValidBtn(self): + self.page.mouse.wheel(0, random.randint(400, 500)) self.page.evaluate("""document.getElementsByClassName("btn")[0].click();""") def clear_app_data(self):