airtest使用poco方法的斷言知識


Airtest的斷言語句

1、驗證UI界面

assert_exists  和  assert_not_exists  兩個接口來斷言一張圖片存在或不存在於當前畫面中。

 

2、驗證數值

assert_equal  和  assert_not_equal  來斷言傳入的兩個值相等或者不相等。

操作:

# assert_equal("實際值", "預測值", "請填寫測試點.")

# 獲取控件的“text”屬性值
value = poco("com.miui.calculator:id/btn_8_s").attr("text")
assert_equal(value, "8", "按鈕值為8")

 

斷言相關的知識——處理斷言失敗

不論是airtest提供的斷言接口,還是Airtest-selenium提供的斷言接口,如果斷言失敗,都會引發AssertionError,從而導致腳本執行終止;如果不想腳本因為一個斷言失敗就終止,可以將斷言用try語句包起來:

value = poco("com.miui.calculator:id/btn_8_s").attr("text")

try:
    assert_equal(value, "8", "按鈕值為8")
except AssertionError:
    print("按鈕值斷言失敗")

  

轉載:https://mp.weixin.qq.com/s/DEe-Emyi0hN0JZA83i1Wmg

 

 

 

 


免責聲明!

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



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