Python+Appium 獲取 toast 方法的封裝
阿新 • • 發佈:2018-01-13
ted ext 查找 sage pre self. ber 一次 pos
獲取toast內容方法封裝如下:
def get_Toast(self,message): #查找toast值
‘‘‘
method explain:查找toast的值,與find_Toast實現方法一樣,只是不同的2種寫法
parameter explain:【text】查找的toast值
Usage:
device.get_Toast(‘再按一次退出iBer‘)
‘‘‘
logging.info("查找toast值---‘%s‘" %(message))
try:
message = ‘//*[@text=\‘{}\‘]‘.format(message)
ele = WebDriverWait(self.driver,5,0.5).until(expected_conditions.presence_of_element_located((By.XPATH,message)))
return ele.get_attribute("text")
logging.info("查找到toast----%s"%message)
except:
logging.error( "未查找到toast----%s"%message)
return False
Python+Appium 獲取 toast 方法的封裝