From 7cf44e01538c5cbd691c62641110e6cad1b589c3 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Mon, 3 Mar 2025 15:04:13 +0800 Subject: [PATCH] 'commit' --- AI/Ylt/Upload.py | 59 ++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/AI/Ylt/Upload.py b/AI/Ylt/Upload.py index c7178bd7..960ee529 100644 --- a/AI/Ylt/Upload.py +++ b/AI/Ylt/Upload.py @@ -145,7 +145,7 @@ def uploadVideo(page, video_path): # 发布节目 -def publish(page): +def publish(page, title, width, height): print("点击编辑节目...") jiemu_library = page.get_by_text("编辑节目") # 通过 text 定位编辑节目 jiemu_library.click() @@ -165,55 +165,51 @@ def publish(page): print("定位目标 元素...") canvas_element = page.locator("canvas#proCanvas") # 定位 元素 + wait() # 执行拖动操作 print("执行拖动操作...") img_element.drag_to(canvas_element) # 将图片拖动到 中 + wait() # 定位并输入文本 print("定位并输入文本...") input_element = page.locator("input[formcontrolname='contentDisplayName']") # 定位 元素 if input_element.is_visible(): - input_element.fill("Test1") # 输入文本 + input_element.fill(title) # 输入文本 else: print(" 元素未找到") + wait() # 定位并输入数值 print("定位并输入数值...") input_element = page.locator("input[formcontrolname='width']").nth(0) # 定位 元素 if input_element.is_visible(): - input_element.fill("1280") # 输入数值 + input_element.fill(width) # 输入数值 else: print(" 元素未找到") + wait() # 定位并输入数值 print("定位并输入数值...") input_element = page.locator("input[formcontrolname='height']").nth(0) # 定位 元素 if input_element.is_visible(): - input_element.fill("720") # 输入数值 + input_element.fill(height) # 输入数值 else: print(" 元素未找到") + wait() # 定位并点击“发布”按钮 print("定位并点击“发布”按钮...") publish_button = page.locator("div.btn.publish") # 定位
元素 if publish_button.is_visible(): publish_button.click() # 点击该元素 # 等待 - wait() + wait(2) tree_node = page.locator("mat-tree-node.node-custom-style", has_text="充电站") # 点击 元素 - if tree_node.count() > 0: # 确保元素存在 - tree_node.click() - print("Clicked on the mat-tree-node.") - # 点击确定按钮 - # 定位目标 元素 - confirm_button = page.locator("span.mat-button-wrapper", has_text="确认") - # 点击 元素 - if confirm_button.count() > 0: # 确保元素存在 - confirm_button.click() - print("Clicked on the confirm button.") - else: - print("Confirm button not found.") - - else: - print("mat-tree-node not found.") + tree_node.click() + # 点击确定按钮 + # 定位目标 元素 + confirm_button = page.locator("span.mat-button-wrapper", has_text="确认") + # 点击 元素 + confirm_button.click() # 切换到节目 @@ -295,47 +291,60 @@ def paiCheng(page, keyword, stHour, stMin, stSec, endHour, endMin, endSec): # 定位目标 元素 input_element = page.locator("input#mat-input-3") # 通过 id 定位 input_element.click() + wait() # 定位目标 元素 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) # 第三个输入框(秒) + wait() # 输入时间 hour_input.fill(stHour) # 输入小时 + wait() minute_input.fill(stMin) # 输入分钟 + wait() second_input.fill(stSec) # 输入秒 - - # 等待 wait() + # 定位