实现代码如下:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class toast:
    def is_toast_exist(self,driver,text,timeout=30, poll_frequency=0.5):
        try:
            toast_loc = ("xpath", "//*[contains(@text,%s)]"%text)
            WebDriverWait(driver, timeout, poll_frequency).until(EC.presence_of_element_located(toast_loc))
            return True
        except:
            return False
posted on 2020-01-07 19:50  badbadboy  阅读(277)  评论(0编辑  收藏  举报