python appium 封装获取toast方法

获取toast text封装,传入toast 部分文本,返回全部文本

    def get_toast_text(self,text):
        try:
            toast_loc = (By.XPATH, "//*[contains(@text,'"+text+"')]")
            logger.info(toast_loc)
            ele = WebDriverWait(self.driver, 10, 0.1).until(EC.presence_of_element_located(toast_loc))
            return ele.text
        except:
            return None

 需要导入

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

欢迎扫码关注自动化技术公众号

 

posted @ 2018-07-21 21:46  testway  阅读(956)  评论(0编辑  收藏  举报