m端判断是否有手机app验证, 更改登录成功页面的判断

This commit is contained in:
work
2025-05-27 13:53:20 +08:00
parent f137321a1f
commit 137f2d5562

View File

@@ -1385,10 +1385,12 @@ def playwright_m_login(username, password, code_2fa=None):
time.sleep(1)
page.click('div[aria-label="Log in"]')
success_login_selector = 'span:has-text("Check your notifications on another device")'
success_login_selector1 = 'span:has-text("Check your notifications on another device")'
success_login_selector2 = 'span:has-text("Go to your authentication app")'
failed_login_selector = 'div[data-bloks-name="bk.components.dialog.Dialog"] > div[aria-label="Wrong Credentials"] > div:nth-child(1)'
# 等成功或失败两个选择的其中一个
page.wait_for_selector(f'{success_login_selector}, {failed_login_selector}', timeout=60000)
page.wait_for_selector(f'{success_login_selector1},{success_login_selector2}, {failed_login_selector}',
timeout=60000)
# 判断是否失败
failed_login = page.query_selector(failed_login_selector)
@@ -1397,6 +1399,9 @@ def playwright_m_login(username, password, code_2fa=None):
logger.info(f"用户名:{username} 密码错误 {failed_login.text_content()}")
raise OperationFailed(failed_login.text_content())
# 判断是否有多重验证
success_login1 = page.query_selector(success_login_selector1)
if success_login1:
# 点击尝试另一种方式验证账号
page.query_selector('div[role="button"][aria-label="Try another way"]').click()
@@ -1408,7 +1413,7 @@ def playwright_m_login(username, password, code_2fa=None):
page.query_selector('div[role="button"][aria-label="Continue"]').click()
# 等待页面
page.wait_for_selector('span:has-text("Go to your authentication app")')
page.wait_for_selector('span:has-text("Go to your authentication app")', timeout=60000)
# 输入2faCode
auth_code = pyotp.TOTP(code_2fa).now()
@@ -1418,7 +1423,7 @@ def playwright_m_login(username, password, code_2fa=None):
page.query_selector('div[role="button"][aria-label="Continue"]').click()
# 等待登录成功
page.wait_for_selector('span:has-text("Save your login info?")', timeout=60000)
page.wait_for_selector('img[data-bloks-name="bk.components.Image"][src*=".fbcdn.net/v/t"]',timeout=60000)
# 成功
logger.info(f"用户名:{username} 账号密码正确")