diff --git a/AI/Ylt/Upload.py b/AI/Ylt/Upload.py index 279587da..570bcdb8 100644 --- a/AI/Ylt/Upload.py +++ b/AI/Ylt/Upload.py @@ -2,7 +2,7 @@ import time from playwright.sync_api import Playwright, sync_playwright # 隐藏浏览器 -#HEADLESS = True +# HEADLESS = True HEADLESS = False # 素材的固定文件夹名称 MATERIAL_FOLDER_NAME = '播报充电情况' @@ -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): # 获取所有 元素的文本内容 text_list = spans.evaluate_all("elements => elements.map(span => span.textContent.trim())") - # 找到第一个以 "Test" 开头的 元素 + # 找到第一个以 keyword 开头的 元素 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_element = page.locator("input#mat-input-3") # 通过 id 定位 + input_element.click() + + # 定位目标 元素 + 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) + # 定位