main
HuangHai 5 months ago
parent 8ecce28865
commit 686bfa2647

@ -59,10 +59,31 @@ def run(playwright: Playwright) -> None:
time.sleep(0.5) # 每隔 0.5 秒检查一次
# 定位并点击包含“我的素材”的 <div> 元素
print("定位并点击包含“我的素材”的 <div> 元素...")
print("定位并点击包含“我的素材”")
my_material_div = page.locator("div.mat-tab-label-content:has-text('我的素材')") # 定位 <div> 元素
my_material_div.click() # 点击该元素
time.sleep(1)
# 定位并点击页面中的第一个 <img> 元素
print("定位并点击页面中的第一个 <img> 元素...")
first_img = page.locator("img").nth(0) # 定位第一个 <img> 元素
if first_img.is_visible():
first_img.click() # 点击该元素
# 定位并点击 <mat-icon> 元素
print("定位并点击 <mat-icon> 元素...")
delete_icon = page.locator("mat-icon:has-text('delete')").nth(0) # 定位 <mat-icon> 元素
if delete_icon.is_visible():
delete_icon.click() # 点击该元素
# 定位并点击 <button> 元素
print("定位并点击 <button> 元素...")
confirm_button = page.locator("button:has-text('确定')") # 定位 <button> 元素
if confirm_button.is_visible():
confirm_button.click() # 点击该元素
else:
print("<button> 元素未找到")
else:
print("<mat-icon> 元素未找到")
else:
print("第一个 <img> 元素未找到")
time.sleep(10)

Loading…
Cancel
Save