main
HuangHai 5 months ago
parent d57c881537
commit 094795af4c

@ -211,8 +211,9 @@ def changeJieMu(page):
program_library.click()
time.sleep(1)
# 排程
def paiCheng(page):
def paiCheng(page, keyword):
pc_library = page.get_by_text("排程").nth(0)
pc_library.click()
@ -251,9 +252,9 @@ def paiCheng(page):
# 获取所有 <span> 元素的文本内容
text_list = spans.evaluate_all("elements => elements.map(span => span.textContent.trim())")
# 找到第一个以 "Test" 开头的 <span> 元素
# 找到第一个以 keyword 开头的 <span> 元素
for index, text in enumerate(text_list):
if text.startswith("Test"):
if text.startswith(keyword):
print(f"Found first span with text: {text}")
# 获取元素的句柄并强制点击
span_handle = spans.nth(index).element_handle()
@ -267,7 +268,38 @@ def paiCheng(page):
span_handle.evaluate("element => element.click()")
break
time.sleep(1)
# 定位目标 <input> 元素
input_element = page.locator("input#mat-input-3") # 通过 id 定位
input_element.click()
# 定位目标 <input> 元素
hour_input = page.locator("input.owl-dt-timer-input").nth(0) # 第一个输入框(小时)
minute_input = page.locator("input.owl-dt-timer-input").nth(1) # 第二个输入框(分钟)
second_input = page.locator("input.owl-dt-timer-input").nth(2) # 第三个输入框(秒)
# 输入时间
hour_input.fill("12") # 输入小时
minute_input.fill("00") # 输入分钟
second_input.fill("00") # 输入秒
time.sleep(1)
# 定位 <button> 元素
set_button = page.locator("button.owl-dt-control-button", has_text="Set")
set_button.click()
# 定位目标 <input> 元素
time_input = page.locator("input#mat-input-4") # 通过 id 定位
# 点击 <input> 元素
time_input.click()
# 定位目标 <input> 元素
hour_input = page.locator("input.owl-dt-timer-input").nth(3) # 第一个输入框(小时)
minute_input = page.locator("input.owl-dt-timer-input").nth(4) # 第二个输入框(分钟)
second_input = page.locator("input.owl-dt-timer-input").nth(5) # 第三个输入框(秒)
# 输入时间
hour_input.fill("13") # 输入小时
minute_input.fill("01") # 输入分钟
second_input.fill("00") # 输入秒
def run(playwright: Playwright) -> None:
# 启动浏览器,禁用无头模式
@ -295,7 +327,7 @@ def run(playwright: Playwright) -> None:
# changeJieMu(page)
# 排程
paiCheng(page)
paiCheng(page, PREFIX_NAME)
time.sleep(100)

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Loading…
Cancel
Save