Implement login module for user authentication in BIP system
This commit is contained in:
31
record.py
31
record.py
@@ -1,7 +1,7 @@
|
||||
import re
|
||||
import time
|
||||
from playwright.sync_api import Playwright, sync_playwright, expect, TimeoutError as PWTimeoutError
|
||||
import time
|
||||
from login import login
|
||||
|
||||
def click_button_until_disappear(frame, button_name="保存提交", interval=5, max_attempts=None, max_duration=None):
|
||||
"""
|
||||
@@ -115,27 +115,14 @@ def get_input_by_label(frame, label_text: str, label_locator=None):
|
||||
return None
|
||||
|
||||
def run(playwright: Playwright) -> None:
|
||||
browser = playwright.chromium.launch(headless=False)
|
||||
context = browser.new_context(ignore_https_errors=True)
|
||||
page = context.new_page()
|
||||
|
||||
# 1. 登录主页面
|
||||
page.goto("https://68.11.34.30:8082/yonbip/resources/uap/rbac/login/main/index.html")
|
||||
|
||||
# 提取主 iframe
|
||||
main_frame = page.locator("#forwardFrame").content_frame
|
||||
|
||||
main_frame.get_by_role("textbox", name="用户名").fill("BLDpengqiangqiang")
|
||||
main_frame.get_by_role("textbox", name="密码").fill("Cqbld123456.")
|
||||
main_frame.get_by_role("button", name="登录").click()
|
||||
|
||||
# 2. 处理强制登录弹窗(判断是否存在)
|
||||
confirm_btn = main_frame.get_by_role("button", name="确定")
|
||||
if confirm_btn.count() > 0:
|
||||
confirm_btn.click()
|
||||
print("强制登录")
|
||||
else:
|
||||
print("正常登录")
|
||||
# 1. 登录
|
||||
browser, context, page, main_frame = login(
|
||||
playwright=playwright,
|
||||
username="BLDpengqiangqiang",
|
||||
password="Cqbld123456.",
|
||||
headless=False,
|
||||
ignore_https_errors=True
|
||||
)
|
||||
|
||||
# 3. 点击打开“补货安排”
|
||||
main_frame.locator("i").first.click() # 假设是某个新建按钮
|
||||
|
||||
Reference in New Issue
Block a user