元素...")
+ print("定位并点击包含“我的素材”")
my_material_div = page.locator("div.mat-tab-label-content:has-text('我的素材')") # 定位
元素
my_material_div.click() # 点击该元素
- time.sleep(1)
+
+ # 定位并点击页面中的第一个
![]()
元素
+ print("定位并点击页面中的第一个
![]()
元素...")
+ first_img = page.locator("img").nth(0) # 定位第一个
![]()
元素
+ if first_img.is_visible():
+ first_img.click() # 点击该元素
+ # 定位并点击
元素
+ print("定位并点击 元素...")
+ delete_icon = page.locator("mat-icon:has-text('delete')").nth(0) # 定位 元素
+ if delete_icon.is_visible():
+ delete_icon.click() # 点击该元素
+ # 定位并点击