try to emulator move
This commit is contained in:
+36
-11
@@ -24,12 +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
|
||||
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
|
||||
@@ -56,10 +61,16 @@ class CommandorPage:
|
||||
}
|
||||
|
||||
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,300))
|
||||
self._checkCgu()
|
||||
# wait for sms_code field
|
||||
self.clickOnValidBtn()
|
||||
@@ -76,7 +87,7 @@ class CommandorPage:
|
||||
otp_sent.wait_for(state='visible')
|
||||
message = self.page.content()
|
||||
# print("message is:" + message)
|
||||
time.sleep(2)
|
||||
time.sleep(get_random_wait_time())
|
||||
if CONFIRMED_MESSAGE in message:
|
||||
# publish the successful message
|
||||
self.logger.info("url is " + self.page.url)
|
||||
@@ -120,6 +131,7 @@ class CommandorPage:
|
||||
def _setPhoneCountryAndStore(self):
|
||||
# document.getElementById("prefer").value = \"faubourg\";
|
||||
self.page.evaluate("""()=>{
|
||||
document.getElementById("phone_country").focus();
|
||||
document.getElementById("phone_country").value = \"FR\" }""")
|
||||
|
||||
def _setPhoneNumber(self, phoneNumber):
|
||||
@@ -128,7 +140,9 @@ class CommandorPage:
|
||||
|
||||
def _setName(self, lastName, firstName):
|
||||
self.page.evaluate("""(name)=> {
|
||||
document.getElementById("surname").focus();
|
||||
document.getElementById("surname").value = name.lastName;
|
||||
document.getElementById("name").focus();
|
||||
document.getElementById("name").value = name.firstName}""", {'lastName': lastName, 'firstName': firstName})
|
||||
|
||||
def getErrors(self):
|
||||
@@ -137,13 +151,20 @@ class CommandorPage:
|
||||
print(items.inner_html())
|
||||
|
||||
def _set_email(self, email):
|
||||
self.page.evaluate("""(email)=>document.getElementById("email").value = email""", email)
|
||||
self.page.evaluate("""(email)=>{
|
||||
document.getElementById("email").focus();
|
||||
document.getElementById("email").value = email;}""", email)
|
||||
|
||||
def setIdNumber(self, id):
|
||||
self.page.evaluate(""" (id) => document.getElementById("passport_id").value = id""", id)
|
||||
self.page.evaluate(""" (id) =>{
|
||||
document.getElementById("passport_id").focus();
|
||||
document.getElementById("passport_id").value = id}""", id)
|
||||
|
||||
def _checkCgu(self):
|
||||
self.page.evaluate("""document.getElementById("cgu").checked = true;
|
||||
self.page.evaluate("""
|
||||
document.getElementById("cgu").focus();
|
||||
document.getElementById("cgu").checked = true;
|
||||
document.getElementById("processing").focus();
|
||||
document.getElementById("processing").checked = true""")
|
||||
|
||||
def clickOnValidBtn(self):
|
||||
@@ -153,6 +174,8 @@ class CommandorPage:
|
||||
pass
|
||||
|
||||
def fill_otp(self, otp: str):
|
||||
self.page.focus(OTP_FIELD_ID)
|
||||
time.sleep(get_random_wait_time())
|
||||
self.page.fill(OTP_FIELD_ID, otp)
|
||||
|
||||
def reset_air_plan_mode(self):
|
||||
@@ -215,10 +238,12 @@ def wait_for_otp(event: threading.Event, commandor: CommandorPage):
|
||||
|
||||
if __name__ == '__main__':
|
||||
# event = launch_page(wait_for_otp)
|
||||
import urllib.request
|
||||
|
||||
proxy = urllib.request.ProxyHandler({'https': 'http://panleicim-res-fr-121:94sY7zwBG13i@gw.ntnt.io:5959'})
|
||||
opener = urllib.request.build_opener(proxy)
|
||||
urllib.request.install_opener(opener)
|
||||
content = urllib.request.urlopen('https://api.ipify.org').read()
|
||||
print(content)
|
||||
time = get_random_wait_time()
|
||||
print(time)
|
||||
# import urllib.request
|
||||
#
|
||||
# proxy = urllib.request.ProxyHandler({'https': 'http://panleicim-res-fr-121:94sY7zwBG13i@gw.ntnt.io:5959'})
|
||||
# opener = urllib.request.build_opener(proxy)
|
||||
# urllib.request.install_opener(opener)
|
||||
# content = urllib.request.urlopen('https://api.ipify.org').read()
|
||||
# print(content)
|
||||
|
||||
Reference in New Issue
Block a user