test with iphone

This commit is contained in:
2022-04-02 09:48:55 +02:00
parent 939a0668fc
commit e26dd3b865
4 changed files with 34 additions and 24 deletions
+18 -23
View File
@@ -17,7 +17,8 @@ RDV_URL = "https://rendezvousparis.hermes.com/client/register"
#
# RDV_URL = "file:///Users/lpan/Downloads/test_appointment.html"
# RDV_URL = "https://api.ipify.org"
# RDV_URL = "https://bot.sannysoft.com/"
# RDV_URL = "https://duoyi.org/"
# RDV_URL ="https://bot.sannysoft.com/"
otp_value = None
user_agent_list = ExcelHelper().read_user_agent_list()
OTP_FIELD_ID = "#sms_code"
@@ -42,17 +43,10 @@ class CommandorPage:
# reset otp_value to None
self.otp_value = None
with sync_playwright() as pwright:
firefox_user_agents = filter(lambda user_agent: "firefox" in user_agent.lower(), user_agent_list)
firefox_user_agents_list = list(firefox_user_agents)
user_agent = random.choice(firefox_user_agents_list)
# if "chrome" in user_agent.lower():
# self.browser = pwright.chromium.launch(headless=False, timeout=90000, proxy=proxy)
# elif "firefox" in user_agent.lower():
# self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
# else:
devices = random.choice(params.DEVICES)
first_page = None
while first_page is None:
first_page = self.start_brower(proxy, pwright, user_agent)
first_page = self.start_brower(proxy, pwright, devices)
proxy_username = "panleicim-res-fr-" + get_random_id_number_for_proxy()
self.logger.info("proxy_username is " + proxy_username)
proxy = {
@@ -70,7 +64,6 @@ class CommandorPage:
self._checkCgu()
# wait for sms_code field
self.clickOnValidBtn()
# self.page.goto("file:///Users/lpan/Downloads/input_otp.html")
otp_input = self.page.locator(OTP_FIELD_ID)
otp_input.wait_for(state='visible', timeout=90000)
on_ready_for_otp(e, self)
@@ -93,21 +86,23 @@ class CommandorPage:
self.logger.info("timeout")
self.reset_air_plan_mode()
def start_brower(self, proxy, pwright, user_agent) -> Union[str, None]:
def start_brower(self, proxy, pwright, device) -> Union[str, None]:
try:
self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
self.logger.info("user_agent is " + user_agent)
context = self.browser.new_context(user_agent = user_agent, screen={
"width": 360,
"height": 640
}, viewport={
"width": 360,
"height": 640
}, has_touch=True)
self.browser = pwright.webkit.launch(headless=False, timeout=90000, proxy=proxy)
self.logger.info("user_agent is " + device)
pixel_2 = pwright.devices[device]
context = self.browser.new_context(**pixel_2, locale='en-GB')
self.page = context.new_page()
# hide webdriver information
self.page.add_init_script("""() => Object.defineProperty(navigator,'webdriver',{get: () => undefined};
() => Object.defineProperty(navigator,'platform',{get: () => "Linux armv7l"};""")
self.page.add_init_script("""() => {
Object.defineProperty(navigator,'webdriver',{get: () => undefined});
() => {Object.defineProperty(navigator, 'platform', {
get: () => {
return "iPhone";
}
})};
}
""")
# self.page.add_init_script("""""")
self.page.on("load", self._on_page_loaded)
self.page.goto(RDV_URL, timeout=90000)
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
Object.defineProperty(navigator, 'webdriver', {get: () => undefined});
Object.defineProperty(navigator, 'platform', {
get: () => {
return "Linux armv7l";
}, set: (a) => {
}
});
() => {Object.defineProperty(navigator, 'platform', {
get: () => {
return "iPhone";
}
})}
+3 -1
View File
@@ -28,4 +28,6 @@ oracle_log_sender = LogSender()
# proxy
PROXY_SERVER = "http://gw.ntnt.io:5959"
PROXY_USERNAME = "panleicim-res-fr-192012"
PROXY_PASSWORD = "94sY7zwBG13i"
PROXY_PASSWORD = "94sY7zwBG13i"
DEVICES = ['iPad (gen 6)', 'iPad (gen 6) landscape', 'iPad (gen 7)', 'iPad (gen 7) landscape', 'iPad Mini', 'iPad Mini landscape', 'iPad Pro 11', 'iPad Pro 11 landscape', 'iPhone 6', 'iPhone 6 landscape', 'iPhone 6 Plus', 'iPhone 6 Plus landscape', 'iPhone 7', 'iPhone 7 landscape', 'iPhone 7 Plus', 'iPhone 7 Plus landscape', 'iPhone 8', 'iPhone 8 landscape', 'iPhone 8 Plus', 'iPhone 8 Plus landscape', 'iPhone SE', 'iPhone SE landscape', 'iPhone X', 'iPhone X landscape', 'iPhone XR', 'iPhone XR landscape', 'iPhone 11', 'iPhone 11 landscape', 'iPhone 11 Pro', 'iPhone 11 Pro landscape', 'iPhone 11 Pro Max', 'iPhone 11 Pro Max landscape', 'iPhone 12', 'iPhone 12 landscape', 'iPhone 12 Pro', 'iPhone 12 Pro landscape', 'iPhone 12 Pro Max', 'iPhone 12 Pro Max landscape', 'iPhone 12 Mini','iPhone 13', 'iPhone 13 landscape', 'iPhone 13 Pro', 'iPhone 13 Pro landscape', 'iPhone 13 Pro Max', 'iPhone 13 Mini']