You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
855 B
24 lines
855 B
import time
|
|
from Config import *
|
|
# 等待
|
|
def wait(seconds=0.5):
|
|
time.sleep(seconds)
|
|
|
|
|
|
|
|
# 登录
|
|
def login(page):
|
|
# 打开登录页面
|
|
page.goto("https://ww1.colorlightcloud.com/login", wait_until="domcontentloaded") # 等待 DOM 加载完成
|
|
# 输入用户名
|
|
username_input = page.locator("#mat-input-0") # 通过 id 定位用户名输入框
|
|
username_input.fill(USERNAME)
|
|
# 输入密码
|
|
password_input = page.locator("input[type='password']") # 根据实际元素定位密码输入框
|
|
password_input.fill(PASSWORD)
|
|
# 点击登录按钮
|
|
login_button = page.locator("button.color-login-btn") # 通过 class 定位登录按钮
|
|
login_button.click()
|
|
# 等待登录成功
|
|
page.wait_for_url("https://ww1.colorlightcloud.com/home", timeout=60000) # 等待跳转到 home 页面
|