|
|
|
@ -41,7 +41,7 @@ def run(playwright: Playwright) -> None:
|
|
|
|
|
print("点击播报充电情况...")
|
|
|
|
|
playback_charge_status = page.get_by_text("播报充电情况")
|
|
|
|
|
playback_charge_status.dblclick()
|
|
|
|
|
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
# 检查 <span> 元素是否存在
|
|
|
|
|
print("检查 <span> 元素是否存在...")
|
|
|
|
|
if page.locator("span.media-group-name").count() > 0:
|
|
|
|
@ -82,7 +82,7 @@ def run(playwright: Playwright) -> None:
|
|
|
|
|
|
|
|
|
|
# 点击 "播报充电情况"
|
|
|
|
|
print("点击播报充电情况...")
|
|
|
|
|
playback_charge_status = page.get_by_text("播报充电情况")
|
|
|
|
|
playback_charge_status = page.get_by_text("播报充电情况").nth(0)
|
|
|
|
|
playback_charge_status.dblclick()
|
|
|
|
|
|
|
|
|
|
# 点击“上传”按钮
|
|
|
|
@ -105,10 +105,70 @@ def run(playwright: Playwright) -> None:
|
|
|
|
|
print("上传进行中...")
|
|
|
|
|
time.sleep(0.5) # 每隔 0.5 秒检查一次
|
|
|
|
|
|
|
|
|
|
# 定位并点击包含“我的素材”的 <div> 元素
|
|
|
|
|
print("定位并点击包含“我的素材”")
|
|
|
|
|
my_material_div = page.locator("div.mat-tab-label-content:has-text('我的素材')") # 定位 <div> 元素
|
|
|
|
|
my_material_div.click() # 点击该元素
|
|
|
|
|
|
|
|
|
|
print("点击编辑节目...")
|
|
|
|
|
jiemu_library = page.get_by_text("编辑节目") # 通过 text 定位编辑节目
|
|
|
|
|
jiemu_library.click()
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
|
|
# 点击 "播报充电情况"
|
|
|
|
|
print("点击播报充电情况...")
|
|
|
|
|
playback_charge_status = page.locator("span:has-text('播报充电情况')").nth(0) # 定位 <span> 元素
|
|
|
|
|
if playback_charge_status.is_visible():
|
|
|
|
|
playback_charge_status.click() # 点击该元素
|
|
|
|
|
# 点击 <img> 元素
|
|
|
|
|
print("点击 <img> 元素...")
|
|
|
|
|
img_element = page.locator("img.grid-img").nth(0) # 定位 <img> 元素
|
|
|
|
|
if img_element.is_visible():
|
|
|
|
|
# 定位目标 <canvas> 元素
|
|
|
|
|
print("定位目标 <canvas> 元素...")
|
|
|
|
|
canvas_element = page.locator("canvas#proCanvas") # 定位 <canvas> 元素
|
|
|
|
|
|
|
|
|
|
# 执行拖动操作
|
|
|
|
|
print("执行拖动操作...")
|
|
|
|
|
img_element.drag_to(canvas_element) # 将图片拖动到 <canvas> 中
|
|
|
|
|
|
|
|
|
|
# 定位并输入文本
|
|
|
|
|
print("定位并输入文本...")
|
|
|
|
|
input_element = page.locator("input[formcontrolname='contentDisplayName']") # 定位 <input> 元素
|
|
|
|
|
if input_element.is_visible():
|
|
|
|
|
input_element.fill("Test1") # 输入文本
|
|
|
|
|
else:
|
|
|
|
|
print("<input> 元素未找到")
|
|
|
|
|
# 定位并输入数值
|
|
|
|
|
print("定位并输入数值...")
|
|
|
|
|
input_element = page.locator("input[formcontrolname='width']").nth(0) # 定位 <input> 元素
|
|
|
|
|
if input_element.is_visible():
|
|
|
|
|
input_element.fill("1280") # 输入数值
|
|
|
|
|
else:
|
|
|
|
|
print("<input> 元素未找到")
|
|
|
|
|
# 定位并输入数值
|
|
|
|
|
print("定位并输入数值...")
|
|
|
|
|
input_element = page.locator("input[formcontrolname='height']").nth(0) # 定位 <input> 元素
|
|
|
|
|
if input_element.is_visible():
|
|
|
|
|
input_element.fill("720") # 输入数值
|
|
|
|
|
else:
|
|
|
|
|
print("<input> 元素未找到")
|
|
|
|
|
# 定位并点击“发布”按钮
|
|
|
|
|
print("定位并点击“发布”按钮...")
|
|
|
|
|
publish_button = page.locator("div.btn.publish") # 定位 <div> 元素
|
|
|
|
|
if publish_button.is_visible():
|
|
|
|
|
publish_button.click() # 点击该元素
|
|
|
|
|
# # 定位并点击 <mat-tree-node> 元素
|
|
|
|
|
# print("定位并点击 <mat-tree-node> 元素...")
|
|
|
|
|
# tree_node = page.locator(
|
|
|
|
|
# "mat-tree-node.node-custom-style:has-text('充电站')") # 定位 <mat-tree-node> 元素
|
|
|
|
|
# if tree_node.is_visible():
|
|
|
|
|
# tree_node.click() # 点击该元素
|
|
|
|
|
# else:
|
|
|
|
|
# print("<mat-tree-node> 元素未找到")
|
|
|
|
|
else:
|
|
|
|
|
print("<div> 元素未找到")
|
|
|
|
|
else:
|
|
|
|
|
print("<img> 元素未找到")
|
|
|
|
|
else:
|
|
|
|
|
print("<span> 元素未找到")
|
|
|
|
|
time.sleep(60)
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"操作过程中发生错误: {e}")
|
|
|
|
|