zoukankan      html  css  js  c++  java
  • Appium-Python3--UI自动化-[-3-]-元素定位-获取APP中的toast,判断该元素是否存在

    获取如图的toast提示

     

     直接上代码:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
     
    def is_toast_exist(driver,text=None,timeout=30,poll_frequency=0.5):
     
       '''is toast exist, return True or False
       :Agrs:
        - driver - 传driver
        - text   - 页面上看到的文本内容
        - timeout - 最大超时时间,默认30s
        - poll_frequency  - 间隔查询时间,默认0.5s查询一次
       :Usage:
        is_toast_exist(driver, "看到的内容")
       '''
     
       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
  • 相关阅读:
    ORACLE的自定义排序
    PDA上一个UDP通讯客户端
    构造
    sort()的使用
    VC2012链接mySql
    宏的一些代码
    试卷
    疑问
    代码1
    vector学习
  • 原文地址:https://www.cnblogs.com/chushujin/p/9901453.html
Copyright © 2011-2022 走看看