方法:
增加AppiumLibrary內部關鍵字
C:\Python37\Lib\site-packages\AppiumLibrary\keywords_applicationmanagement.py
具體實現:
- 找到 C:\Python37\Lib\site-packages\AppiumLibrary\keywords_applicationmanagement.py文件,文件末尾增加代碼.
def get_toast_text(self, text, timeout=10, poll_frequency=0.1):
“”"
功能:獲取Toast的文本信息
參數:text需要檢查的提示信息 time檢查總時間 poll_frequency檢查時間間隔
返回值:返回與之匹配到的toast信息
作者:XXX
日期:20190415
更新記錄:
“”"
try:
driver = self._current_application()
toast_element = (By.XPATH, ‘.//*[contains(@text,’ + ‘"’ + text + ‘"’ + ‘)]’)
toast = WebDriverWait(driver, timeout, poll_frequency).until(EC.presence_of_element_located(toast_element))
return toast.text
except:
logging.info(“toast提示文本沒有發現!”)
return False
如圖:
- 保存後重新打開Robot Framework RIDE,則可像其它關鍵字一樣調用