airtest中斷言存在assert_exists、斷言包含assert_equal和判斷是否存在exists的使用


#斷言存在

assert_exists(Template(r"tpl1611284952927.png", record_pos=(0.062, -0.287), resolution=(720, 1280)), "請填寫測試點")

#斷言包含
value = poco("com.createwit.kaidan:id/synthesize_tv").attr("text")
try:
  assert_equal(value, "綜合", "按鈕值為:綜合")
except AssertionError:
  print("按鈕值斷言失敗")


#判斷是否存在某個按鈕,具有則點擊,不具有則執行其他操作
if exists(Template(r"tpl1611283287349.png", record_pos=(0.004, -0.157), resolution=(720, 1280))) :
  touch exists(Template(r"tpl1611283287349.png", record_pos=(0.004, -0.157), resolution=(720, 1280)))
else:
  print("沒有這個選項")


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM