|
|
@@ -186,53 +186,53 @@ class TlsPlugin(IVSPlg):
|
|
|
init_y = random.randint(10, viewport_height - 10)
|
|
|
self.mouse.move(init_x, init_y)
|
|
|
|
|
|
- btn_selector = '#btn-login'
|
|
|
+ btn_selector = 'tag:button@@text():Login'
|
|
|
if not self.page.wait.ele_displayed(btn_selector, timeout=3):
|
|
|
- register_btn = self.page.ele("tag:a@@href:login")
|
|
|
- self.mouse.human_click_ele(register_btn)
|
|
|
+ login_btn = self.page.ele("tag:a@@href:login")
|
|
|
+ self.mouse.human_click_ele(login_btn)
|
|
|
time.sleep(3)
|
|
|
if not self.page.wait.ele_displayed(btn_selector, timeout=10):
|
|
|
raise BizLogicError(message=f"Can't find selector={btn_selector}")
|
|
|
time.sleep(random.uniform(0.5, 1))
|
|
|
|
|
|
- recaptchav2_token = ""
|
|
|
- if self.page.ele('.g-recaptcha') or self.page.ele('xpath://iframe[contains(@src, "recaptcha")]'):
|
|
|
- self._log("Solving ReCaptcha...")
|
|
|
- rc_params = {
|
|
|
- "type": "ReCaptchaV2TaskProxyLess",
|
|
|
- "page": self.page.url,
|
|
|
- "siteKey": "6LcDpXcfAAAAAM7wOEsF_38DNsL20tTvPTKxpyn0",
|
|
|
- "apiToken": self.free_config.get("capsolver_key", "")
|
|
|
- }
|
|
|
- recaptchav2_token = self._solve_recaptcha(rc_params)
|
|
|
+ # recaptchav2_token = ""
|
|
|
+ # if self.page.ele('.g-recaptcha') or self.page.ele('xpath://iframe[contains(@src, "recaptcha")]'):
|
|
|
+ # self._log("Solving ReCaptcha...")
|
|
|
+ # rc_params = {
|
|
|
+ # "type": "ReCaptchaV2TaskProxyLess",
|
|
|
+ # "page": self.page.url,
|
|
|
+ # "siteKey": "6LcDpXcfAAAAAM7wOEsF_38DNsL20tTvPTKxpyn0",
|
|
|
+ # "apiToken": self.free_config.get("capsolver_key", "")
|
|
|
+ # }
|
|
|
+ # recaptchav2_token = self._solve_recaptcha(rc_params)
|
|
|
|
|
|
username = self.config.account.username
|
|
|
password = self.config.account.password
|
|
|
|
|
|
- input_ele = self.page.ele('#email-input-field')
|
|
|
+ input_ele = self.page.ele('tag:label@@text():Email').next()
|
|
|
self.mouse.human_click_ele(input_ele)
|
|
|
time.sleep(random.uniform(0.2, 0.6))
|
|
|
self.keyboard.type_text(username, humanize=True)
|
|
|
|
|
|
time.sleep(random.uniform(0.5, 1.2))
|
|
|
|
|
|
- pwd_ele = self.page.ele('#password-input-field')
|
|
|
- self.mouse.human_click_ele(pwd_ele)
|
|
|
+ input_ele = self.page.ele('tag:label@@text():Password').next()
|
|
|
+ self.mouse.human_click_ele(input_ele)
|
|
|
time.sleep(random.uniform(0.2, 0.6))
|
|
|
self.keyboard.type_text(password, humanize=True)
|
|
|
|
|
|
- if recaptchav2_token:
|
|
|
- inject_recaptchav2_token_js = f"""
|
|
|
- var g = document.getElementById('g-recaptcha-response');
|
|
|
- if(g) {{ g.value = "{recaptchav2_token}"; }}
|
|
|
- """
|
|
|
- self._log("Inject ReCaptchaV2 Token via JS...")
|
|
|
- self.page.run_js(inject_recaptchav2_token_js)
|
|
|
- time.sleep(random.uniform(0.5, 1.0))
|
|
|
+ # if recaptchav2_token:
|
|
|
+ # inject_recaptchav2_token_js = f"""
|
|
|
+ # var g = document.getElementById('g-recaptcha-response');
|
|
|
+ # if(g) {{ g.value = "{recaptchav2_token}"; }}
|
|
|
+ # """
|
|
|
+ # self._log("Inject ReCaptchaV2 Token via JS...")
|
|
|
+ # self.page.run_js(inject_recaptchav2_token_js)
|
|
|
+ # time.sleep(random.uniform(0.5, 1.0))
|
|
|
|
|
|
self._log("Submitting Login...")
|
|
|
time.sleep(random.uniform(0.3, 0.8))
|
|
|
- login_btn = self.page.ele('#btn-login')
|
|
|
+ login_btn = self.page.ele('tag:button@@text():Login')
|
|
|
self.mouse.human_click_ele(login_btn)
|
|
|
|
|
|
self._log("Waiting for redirect...")
|
|
|
@@ -246,54 +246,54 @@ class TlsPlugin(IVSPlg):
|
|
|
self.page.wait.load_start()
|
|
|
time.sleep(5)
|
|
|
|
|
|
- groups = self._parse_travel_groups(self.page.html)
|
|
|
- location = self.free_config.get('location')
|
|
|
- for g in groups:
|
|
|
- if g['location'] == location:
|
|
|
- self.travel_group = g
|
|
|
- break
|
|
|
+ # groups = self._parse_travel_groups(self.page.html)
|
|
|
+ # location = self.free_config.get('location')
|
|
|
+ # for g in groups:
|
|
|
+ # if g['location'] == location:
|
|
|
+ # self.travel_group = g
|
|
|
+ # break
|
|
|
|
|
|
- if not self.travel_group:
|
|
|
- self._save_screenshot("group_not_found")
|
|
|
- raise NotFoundError(f"Group not found for {location}")
|
|
|
+ # if not self.travel_group:
|
|
|
+ # self._save_screenshot("group_not_found")
|
|
|
+ # raise NotFoundError(f"Group not found for {location}")
|
|
|
|
|
|
- formgroup_id = self.travel_group.get('group_number')
|
|
|
+ # formgroup_id = self.travel_group.get('group_number')
|
|
|
|
|
|
- btn_selector = f'tag:button@@name=formGroupId@@value={formgroup_id}'
|
|
|
- self._log(f"Waiting for visible button to render: {formgroup_id}...")
|
|
|
+ # btn_selector = f'tag:button@@name=formGroupId@@value={formgroup_id}'
|
|
|
+ # self._log(f"Waiting for visible button to render: {formgroup_id}...")
|
|
|
|
|
|
- self.page.wait.eles_loaded(btn_selector, timeout=15)
|
|
|
+ # self.page.wait.eles_loaded(btn_selector, timeout=15)
|
|
|
|
|
|
- buttons = self.page.eles(btn_selector)
|
|
|
- select_btn = None
|
|
|
- for btn in reversed(buttons):
|
|
|
- try:
|
|
|
- w, h = btn.rect.size
|
|
|
- if w > 0 and h > 0:
|
|
|
- select_btn = btn
|
|
|
- break
|
|
|
- except Exception:
|
|
|
- continue
|
|
|
- if not select_btn:
|
|
|
- self._save_screenshot("visible_button_not_found")
|
|
|
- raise BizLogicError(f"Can't find any visible Select button for group {formgroup_id}")
|
|
|
- time.sleep(random.uniform(0.5, 1.2))
|
|
|
- self.mouse.human_click_ele(select_btn)
|
|
|
+ # buttons = self.page.eles(btn_selector)
|
|
|
+ # select_btn = None
|
|
|
+ # for btn in reversed(buttons):
|
|
|
+ # try:
|
|
|
+ # w, h = btn.rect.size
|
|
|
+ # if w > 0 and h > 0:
|
|
|
+ # select_btn = btn
|
|
|
+ # break
|
|
|
+ # except Exception:
|
|
|
+ # continue
|
|
|
+ # if not select_btn:
|
|
|
+ # self._save_screenshot("visible_button_not_found")
|
|
|
+ # raise BizLogicError(f"Can't find any visible Select button for group {formgroup_id}")
|
|
|
+ # time.sleep(random.uniform(0.5, 1.2))
|
|
|
+ # self.mouse.human_click_ele(select_btn)
|
|
|
|
|
|
- self._log("Waiting for url redirect...")
|
|
|
- self.page.wait.url_change('travel-groups', exclude=True, timeout=45)
|
|
|
- time.sleep(2)
|
|
|
+ # self._log("Waiting for url redirect...")
|
|
|
+ # self.page.wait.url_change('travel-groups', exclude=True, timeout=45)
|
|
|
+ # time.sleep(2)
|
|
|
|
|
|
- if "travel-groups" in self.page.url or "auth" in self.page.url:
|
|
|
- raise BizLogicError(message="Redirect to service-level Failed!")
|
|
|
+ # if "travel-groups" in self.page.url or "auth" in self.page.url:
|
|
|
+ # raise BizLogicError(message="Redirect to service-level Failed!")
|
|
|
|
|
|
- no_applicant_indicators = [
|
|
|
- "Add a new applicant" in self.page.html,
|
|
|
- "You have not yet added an applicant. Please click the button below to add one." in self.page.html,
|
|
|
- "applicants-information" in self.page.url
|
|
|
- ]
|
|
|
- if any(no_applicant_indicators):
|
|
|
- raise BizLogicError(message=f"No applicant added")
|
|
|
+ # no_applicant_indicators = [
|
|
|
+ # "Add a new applicant" in self.page.html,
|
|
|
+ # "You have not yet added an applicant. Please click the button below to add one." in self.page.html,
|
|
|
+ # "applicants-information" in self.page.url
|
|
|
+ # ]
|
|
|
+ # if any(no_applicant_indicators):
|
|
|
+ # raise BizLogicError(message=f"No applicant added")
|
|
|
|
|
|
btn_selector = '#book-appointment-btn'
|
|
|
self._log(f"Waiting for selector={btn_selector} to render...")
|
|
|
@@ -301,19 +301,20 @@ class TlsPlugin(IVSPlg):
|
|
|
raise BizLogicError(message=f"Waiting for selector={btn_selector} timeout")
|
|
|
self.mouse.human_click_ele(self.page.ele(btn_selector))
|
|
|
|
|
|
- self._log("Waiting for url redirect...")
|
|
|
- self.page.wait.url_change('service-level', exclude=True, timeout=45)
|
|
|
- time.sleep(2)
|
|
|
+ time.sleep(3)
|
|
|
+ # self._log("Waiting for url redirect...")
|
|
|
+ # self.page.wait.url_change('service-level', exclude=True, timeout=45)
|
|
|
+ # time.sleep(2)
|
|
|
|
|
|
- if "service-level" in self.page.url or "auth" in self.page.url:
|
|
|
- raise BizLogicError(message="Redirect to appointment-booking Failed!")
|
|
|
+ # if "service-level" in self.page.url or "auth" in self.page.url:
|
|
|
+ # raise BizLogicError(message="Redirect to appointment-booking Failed!")
|
|
|
|
|
|
btn_selector = 'tag:button@text():Book your appointment'
|
|
|
if not self.page.wait.ele_displayed(btn_selector, timeout=10):
|
|
|
raise BizLogicError(message=f"Waiting for selector={btn_selector} timeout")
|
|
|
|
|
|
self.session_create_time = time.time()
|
|
|
- self._log(f"✅ Login & Navigation Success! Target Group ID: {formgroup_id}")
|
|
|
+ self._log(f"✅ Login & Navigation Success!")
|
|
|
|
|
|
except Exception as e:
|
|
|
self._log(f"Session Create Error: {e}")
|
|
|
@@ -324,7 +325,6 @@ class TlsPlugin(IVSPlg):
|
|
|
def query(self, apt_type: AppointmentType) -> VSQueryResult:
|
|
|
res = VSQueryResult()
|
|
|
res.success = False
|
|
|
- group_num = self.travel_group['group_number']
|
|
|
interest_month = self.free_config.get("interest_month", time.strftime("%m-%Y"))
|
|
|
|
|
|
target_date_obj = datetime.strptime(interest_month, "%m-%Y")
|