Commit 312ca9d4 by baiquan

refactor(service): 优化登录验证流程

- 在滑动滑块验证后添加返回语句,避免继续执行后续代码
-增加对首页标题的检查,提高登录成功后的准确性
-移除滑块验证后的冗余代码,简化验证流程
-调用 listen_login 函数监听登录结果,提高代码复用性
parent 496df7be
...@@ -147,6 +147,7 @@ def listen_login(tab): ...@@ -147,6 +147,7 @@ def listen_login(tab):
continue continue
if login_res['description'] == '滑动滑块进行验证': if login_res['description'] == '滑动滑块进行验证':
verify_captcha(tab) verify_captcha(tab)
return
elif login_res['description'] == '': elif login_res['description'] == '':
logger.info("登录成功") logger.info("登录成功")
return return
...@@ -163,6 +164,9 @@ def listen_check_login(tab): ...@@ -163,6 +164,9 @@ def listen_check_login(tab):
if (login_res['deputy_has_login'] and login_res['subject_has_login'] and login_res['error_code'] == 0 if (login_res['deputy_has_login'] and login_res['subject_has_login'] and login_res['error_code'] == 0
and login_res.get('sec_subject_uid') and login_res.get('sec_user_id')): and login_res.get('sec_subject_uid') and login_res.get('sec_user_id')):
check_result = True check_result = True
if check_result:
if tab.title != "首页":
return False
return check_result return check_result
def verify_captcha(tab): def verify_captcha(tab):
...@@ -201,13 +205,5 @@ def verify_captcha(tab): ...@@ -201,13 +205,5 @@ def verify_captcha(tab):
iframe.actions.hold(_captcha_slider_btn) iframe.actions.hold(_captcha_slider_btn)
iframe.actions.right(x) iframe.actions.right(x)
iframe.actions.release() iframe.actions.release()
for verify_packet in tab.listen.steps(timeout=30): listen_login(tab)
if "captcha/verify" in verify_packet.url:
verify_res = verify_packet.response.body
if verify_res['code'] != 500:
logger.info(f"-------- login_verify: 滑块处理成功!--------")
return return
\ No newline at end of file
else:
logger.error("滑块验证失败")
tab.wait(3)
break
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment