appium(toast处理)
1 from selenium.webdriver.support.ui import WebDriverWait 2 from selenium.webdriver.support import expected_conditions as ES 3 4 def is_toast_exist(driver, text, timeout=3, poll_frequency=0.01): 5 """ 6 获取toast函数封装,就是获取那个一闪而过的提示语。。。 7 :param driver: 8 :param text: 输入一部分进行匹配 9 :param timeout: 10 :param poll_frequency: 11 :return: 12 """ 13 try: 14 toast_loc = ("xpath", ".//*[contains(@text,'%s')]" % text) 15 el = WebDriverWait(driver, timeout, poll_frequency).until(ES.presence_of_element_located(toast_loc)) 16 return el.text 17 except: 18 return False