test with iphone
This commit is contained in:
+17
-22
@@ -17,6 +17,7 @@ RDV_URL = "https://rendezvousparis.hermes.com/client/register"
|
|||||||
#
|
#
|
||||||
# RDV_URL = "file:///Users/lpan/Downloads/test_appointment.html"
|
# RDV_URL = "file:///Users/lpan/Downloads/test_appointment.html"
|
||||||
# RDV_URL = "https://api.ipify.org"
|
# RDV_URL = "https://api.ipify.org"
|
||||||
|
# RDV_URL = "https://duoyi.org/"
|
||||||
# RDV_URL ="https://bot.sannysoft.com/"
|
# RDV_URL ="https://bot.sannysoft.com/"
|
||||||
otp_value = None
|
otp_value = None
|
||||||
user_agent_list = ExcelHelper().read_user_agent_list()
|
user_agent_list = ExcelHelper().read_user_agent_list()
|
||||||
@@ -42,17 +43,10 @@ class CommandorPage:
|
|||||||
# reset otp_value to None
|
# reset otp_value to None
|
||||||
self.otp_value = None
|
self.otp_value = None
|
||||||
with sync_playwright() as pwright:
|
with sync_playwright() as pwright:
|
||||||
firefox_user_agents = filter(lambda user_agent: "firefox" in user_agent.lower(), user_agent_list)
|
devices = random.choice(params.DEVICES)
|
||||||
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:
|
|
||||||
first_page = None
|
first_page = None
|
||||||
while first_page is 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()
|
proxy_username = "panleicim-res-fr-" + get_random_id_number_for_proxy()
|
||||||
self.logger.info("proxy_username is " + proxy_username)
|
self.logger.info("proxy_username is " + proxy_username)
|
||||||
proxy = {
|
proxy = {
|
||||||
@@ -70,7 +64,6 @@ class CommandorPage:
|
|||||||
self._checkCgu()
|
self._checkCgu()
|
||||||
# wait for sms_code field
|
# wait for sms_code field
|
||||||
self.clickOnValidBtn()
|
self.clickOnValidBtn()
|
||||||
# self.page.goto("file:///Users/lpan/Downloads/input_otp.html")
|
|
||||||
otp_input = self.page.locator(OTP_FIELD_ID)
|
otp_input = self.page.locator(OTP_FIELD_ID)
|
||||||
otp_input.wait_for(state='visible', timeout=90000)
|
otp_input.wait_for(state='visible', timeout=90000)
|
||||||
on_ready_for_otp(e, self)
|
on_ready_for_otp(e, self)
|
||||||
@@ -93,21 +86,23 @@ class CommandorPage:
|
|||||||
self.logger.info("timeout")
|
self.logger.info("timeout")
|
||||||
self.reset_air_plan_mode()
|
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:
|
try:
|
||||||
self.browser = pwright.firefox.launch(headless=False, timeout=90000, proxy=proxy)
|
self.browser = pwright.webkit.launch(headless=False, timeout=90000, proxy=proxy)
|
||||||
self.logger.info("user_agent is " + user_agent)
|
self.logger.info("user_agent is " + device)
|
||||||
context = self.browser.new_context(user_agent = user_agent, screen={
|
pixel_2 = pwright.devices[device]
|
||||||
"width": 360,
|
context = self.browser.new_context(**pixel_2, locale='en-GB')
|
||||||
"height": 640
|
|
||||||
}, viewport={
|
|
||||||
"width": 360,
|
|
||||||
"height": 640
|
|
||||||
}, has_touch=True)
|
|
||||||
self.page = context.new_page()
|
self.page = context.new_page()
|
||||||
# hide webdriver information
|
# hide webdriver information
|
||||||
self.page.add_init_script("""() => Object.defineProperty(navigator,'webdriver',{get: () => undefined};
|
self.page.add_init_script("""() => {
|
||||||
() => Object.defineProperty(navigator,'platform',{get: () => "Linux armv7l"};""")
|
Object.defineProperty(navigator,'webdriver',{get: () => undefined});
|
||||||
|
() => {Object.defineProperty(navigator, 'platform', {
|
||||||
|
get: () => {
|
||||||
|
return "iPhone";
|
||||||
|
}
|
||||||
|
})};
|
||||||
|
}
|
||||||
|
""")
|
||||||
# self.page.add_init_script("""""")
|
# self.page.add_init_script("""""")
|
||||||
self.page.on("load", self._on_page_loaded)
|
self.page.on("load", self._on_page_loaded)
|
||||||
self.page.goto(RDV_URL, timeout=90000)
|
self.page.goto(RDV_URL, timeout=90000)
|
||||||
|
|||||||
Binary file not shown.
@@ -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";
|
||||||
|
}
|
||||||
|
})}
|
||||||
@@ -29,3 +29,5 @@ oracle_log_sender = LogSender()
|
|||||||
PROXY_SERVER = "http://gw.ntnt.io:5959"
|
PROXY_SERVER = "http://gw.ntnt.io:5959"
|
||||||
PROXY_USERNAME = "panleicim-res-fr-192012"
|
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']
|
||||||
Reference in New Issue
Block a user