appium获取Toast内容的方法
做自动化测试的时候,可能需要根据弹出的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内容的方法的更多相关文章
- Python+Appium 获取 toast 文本值方法的封装
获取toast内容方法封装如下: def get_Toast(self,message): #查找toast值 ''' method explain:查找toast的值,与find_Toast实现方法 ...
- appium获取toast和操作webview实例
从testerhome上看到很多测试同学分享了toast的获取方式,其中大部分是java版本的,但也有个python版本的:Appium1.7.2 android toast 消息测试 Appium获 ...
- JS获取标签内容的方法
JS获取标签内容的方法 测试代码 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- appium+java(八)获取Toast内容信息
前言 Appium中很经典的问题了,在两年前也就是2017年3月6号07:22分,我才看到appium1.6.3版本的发布,更新内容为Ios上可以实现Toast的获取,而Windows也就是安卓端,还 ...
- Appium+python自动化获取toast消息的方法
转载地址:https://www.cnblogs.com/shangren/p/8191879.html 1. 首先执行这个命令:npm install -g cnpm --registry=http ...
- Appium获取toast消息
Android获取toast,需要在参数里设置automationName:Uiautomator2 设置设备的信息 desired_caps = { 'platformName': 'Android ...
- Appium获取toast消息遇到的问题(一)
一.运行错误 Android获取toast,需要在参数里设置automationName:Uiautomator2 1 # 设置设备的信息 2 desired_caps = { 3 'platform ...
- appium获取toast方法
配置toast请注意: 1.指定desired_caps["automationName"] = "UiAutomator2" 2.要求安装jdk1.8 64位 ...
- Appium获取toast消息(二)
刚接触appium进行移动端设备的UI自动化,在遇到toast消息的时候很是苦恼了一阵,最后通过强大的搜索引擎找到了个相对解决方法,废话不多说,直接贴代码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ...
随机推荐
- SQL实用札记【SQL Sever篇】
目录 从表中去除重复行 逗号分隔字符串转数据表行 跨DB/Server执行SP[分布式事务] 在OpenQuery中执行带参数的SQL语句 从表中去除重复行数据 1. 如果有ID字段,就是具有唯一性的 ...
- 在nodeJS中操作文件系统(二)
在nodeJS中操作文件系统(二) 1. 移动文件或目录 在fs模块中,可以使用rename方法移动文件或目录,使用方法如下: fs.rename(oldPath,newPath,call ...
- CentOS7+ anaconda3 + Python-3.6 + tensorflow-cpu-1.5安装和配置
CentOS7+ anaconda3 + Python-3.6 + tensorflow-cpu-1.5安装和配置 ========================================== ...
- Android failed to start daemon
异常描述:在Eclipse中运行Android项目时Console中出现: The connection to adb is down, and a severe error has occured. ...
- JAVA之多线程概念及其几种实现方法优劣分析
1. 多线程 程序:指令集,静态的概念 进程:操作系统调动程序,是程序的一次动态执行过程,动态的概念 线程:在进程内的多条执行路径 Ps:单核的话进程都是虚拟模拟出来的,多核处理器才可以执行真正的多线 ...
- POJ 1904 King's Quest(SCC的巧妙应用,思维题!!!,经典题)
King's Quest Time Limit: 15000MS Memory Limit: 65536K Total Submissions: 10305 Accepted: 3798 Ca ...
- ETH—Lwip以太网通信
第39章 ETH—Lwip以太网通信 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/ ...
- WCF来传递DataTable的Bug
Wcf,客户端与服务器之间在传递DataTable(由于数据库字段不确定暂时用DataTable而不是用实体对象传递)时,发现有的DataTable可以直接传递没有问题 解决方案: DataTable ...
- linux中原子操作实现方式
原子操作提供了指令原子执行,中间没有中断.就像原子被认为是不可分割颗粒一样,原子操作(atomic operation)是不可分割的操作. 如下面简单的例子: Thread 1 ...
- CM (Cloudera Manager) 的安装,便于CDH的离线部署
一.准备工作 主机个数:n台 操作系统:CentOS 6.5 安装所需软件包: CM: cloudera-manager-el6-cm5.4.3_x86_64.tar.gz CDH parcel: C ...