main
HuangHai 5 months ago
parent 0e196f0130
commit 2cd29ebb65

@ -50,7 +50,7 @@ def delProgram(page, keyword):
print(f"Found element with text: {text}")
# 点击
divs.nth(index).click()
time.sleep(1)
time.sleep(0.5)
# 点击删除按钮
delete_icon = page.locator("mat-icon:has-text('delete')").nth(0)
if delete_icon.is_visible():
@ -60,7 +60,7 @@ def delProgram(page, keyword):
if confirm_button.is_visible():
confirm_button.click() # 点击该元素
cnt = cnt + 1
time.sleep(1)
time.sleep(0.5)
if cnt > 0:
print("删除" + str(cnt) + "个节目")
else:
@ -77,13 +77,13 @@ def delMaterial(page):
# 点击 MATERIAL_FOLDER_NAME
playback_charge_status = page.get_by_text(MATERIAL_FOLDER_NAME)
playback_charge_status.dblclick()
time.sleep(1)
time.sleep(0.5)
# 检查 <span> 元素是否存在
if page.locator("span.media-group-name").count() > 0:
# 鼠标移动到第一个 <span> 元素
first_span = page.locator("span.media-group-name").nth(0) # 定位第一个 <span> 元素
first_span.hover() # 鼠标移动到该元素
time.sleep(1)
time.sleep(0.5)
# 定位并点击外层的 <span> 元素
checkbox_span = page.locator("span.mat-checkbox-inner-container").nth(0) # 定位 <span> 元素
if checkbox_span.is_visible():
@ -96,7 +96,7 @@ def delMaterial(page):
confirm_button = page.locator("button:has-text('确定')")
if confirm_button.is_visible():
confirm_button.click() # 点击该元素
time.sleep(1)
time.sleep(0.5)
print("删除素材完成!")
@ -138,7 +138,7 @@ def publish(page):
print("点击编辑节目...")
jiemu_library = page.get_by_text("编辑节目") # 通过 text 定位编辑节目
jiemu_library.click()
time.sleep(1)
time.sleep(0.5)
# 点击 MATERIAL_FOLDER_NAME
print("点击" + MATERIAL_FOLDER_NAME + "...")
@ -183,7 +183,7 @@ def publish(page):
publish_button = page.locator("div.btn.publish") # 定位 <div> 元素
if publish_button.is_visible():
publish_button.click() # 点击该元素
time.sleep(1)
time.sleep(0.5)
tree_node = page.locator("mat-tree-node.node-custom-style", has_text="充电站")
# 点击 <mat-tree-node> 元素
if tree_node.count() > 0: # 确保元素存在
@ -209,7 +209,7 @@ def changeJieMu(page):
print("点击节目...")
program_library = page.get_by_text("节目").nth(0) # 通过 text 定位媒体库
program_library.click()
time.sleep(1)
time.sleep(0.5)
# 排程
@ -230,7 +230,7 @@ def paiCheng(page, keyword):
# 点击 <span> 元素
if broadcast_span.count() > 0: # 确保元素存在
broadcast_span.click()
time.sleep(1)
time.sleep(0.5)
# 定位目标滑动开关的“滑块”部分
toggle_thumb = page.locator("div.mat-slide-toggle-thumb").nth(0)
# 点击“滑块”部分
@ -239,7 +239,7 @@ def paiCheng(page, keyword):
# + 号
add_icon = page.locator("mat-icon", has_text="add").nth(2)
add_icon.click()
time.sleep(1)
time.sleep(0.5)
# 等待目标对话框出现
dialog = page.get_by_role('dialog', name='选择节目') # 通过对话框标题定位
@ -268,7 +268,7 @@ def paiCheng(page, keyword):
span_handle.evaluate("element => element.click()")
break
time.sleep(1)
time.sleep(0.5)
# 定位目标 <input> 元素
input_element = page.locator("input#mat-input-3") # 通过 id 定位
input_element.click()
@ -282,7 +282,7 @@ def paiCheng(page, keyword):
minute_input.fill("00") # 输入分钟
second_input.fill("00") # 输入秒
time.sleep(1)
time.sleep(0.5)
# 定位 <button> 元素
set_button = page.locator("button.owl-dt-control-button", has_text="Set")
set_button.click()

Loading…
Cancel
Save