金鞍玉勒寻芳客,未信我庐别有春。这篇文章主要讲述appium获取Toast内容的方法相关的知识,希望能为你提供帮助。
做自动化测试的时候,可能需要根据弹出的Toast提示来做下一步判断。这里记录一下获取Toast内容的方法,同时巩固一下显示等待的方法之一WebDriverWait。
from selenium.webdriver.support import expected_conditions as ecdef 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
【appium获取Toast内容的方法】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
推荐阅读
- Android UiAutomator2.0
- Android Studio 打包生成apk
- @RequestMapping value 能够反复吗 [
- RN安卓原生模块
- Android 轮播图
- 转载一行代码加载网络图片到ImageView——Android Picasso
- android 画竖虚线
- 获取APP的类结构信息
- APP切图流程和APP切图命名规范详细完整版