首页 > 移动平台 > 详细

appium获取Toast内容的方法

时间:2018-01-20 23:23:17      阅读:373      评论:0      收藏:0      [点我收藏+]

做自动化测试的时候,可能需要根据弹出的Toast提示来做下一步判断。这里记录一下获取Toast内容的方法,同时巩固一下显示等待的方法之一WebDriverWait。

from selenium.webdriver.support import expected_conditions as ec

def find_toast(self, driver, message, timeout=10, poll=0.01):
    try:
        message = //*[@text=\‘{}\‘].format(message) #Toast内容
        element = WebDriverWait(driver, timeout,poll).until(ec.presence_of_element_located((By.XPATH, message)))
        return True
    except Exception as e:
        print(("Get Toast Error : ", e))
        return False

presence_of_element_located可以替换为

  • title_is
  • title_contains
  • presence_of_element_located
  • visibility_of_element_located   # 和 presence_of_element_located 的作用几乎一样
  • visibility_of
  • presence_of_all_elements_located
  • text_to_be_present_in_element
  • text_to_be_present_in_element_value
  • frame_to_be_available_and_switch_to_it
  • invisibility_of_element_located
  • element_to_be_clickable - it is Displayed and Enabled.
  • staleness_of
  • element_to_be_selected
  • element_located_to_be_selected
  • element_selection_state_to_be
  • element_located_selection_state_to_be
  • alert_is_present

By.XPATH中的XPATH可替换为‘CLASS_NAME‘, ‘CSS_SELECTOR‘, ‘ID‘, ‘LINK_TEXT‘, ‘NAME‘, ‘PARTIAL_LINK_TEXT‘, ‘TAG_NAME‘

 

appium获取Toast内容的方法

原文:https://www.cnblogs.com/mgzc-1508873480/p/8322253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!