Appium 自动化测试(8) -- Appium Python client -- API
最好的学习方法,就是看源码!
在 \appium\webdriver\webdriver.py ,新增了两个封装好定位安卓元素的方法,如 find_element_by_accessibility_id 与 find_element_by_android_uiautomator
如下图,定位“一起玩”tab页:
一、根据UIAutomator定位元素
def test_find_element(self):
self.driver.wait_activity('com.yy.mobile.ui.home.MainActivity',30)
# text 属性的方法
el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("一起玩")')
self.assertIsNotNone(el)
e2 = self.driver.find_element_by_android_uiautomator('new UiSelector().textContains("起玩")')
self.assertIsNotNone(e2)
e3 = self.driver.find_element_by_android_uiautomator('new UiSelector().textStartsWith("一起")')
self.assertIsNotNone(e3)
e4 = self.driver.find_element_by_android_uiautomator('new UiSelector().textMatches("^一起.*")')
self.assertIsNotNone(e4)
# class属性的方法
e5 = self.driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.TextView").text("一起玩")')
self.assertIsNotNone(e5)
# resourceId属性的方法
e6 = self.driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.yy.mobile.plugin.main:id/tab_tab_btn")')
self.assertIsNotNone(e6)
二、根据accessibility_id定位
def find_element_by_accessibility_id(self, id):
"""Finds an element by accessibility id. :Args:
- id - a string corresponding to a recursive element search using the
Id/Name that the native Accessibility options utilize :Usage:
driver.find_element_by_accessibility_id()
"""
return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
对于 Android 就是 content-description
对于 iOS 就是 accessibility identifier
三、看源码可知,Appium 中的Webdriver是Selenium中的webdirver.Remote的子类,所以更多的API,可是在Selenium中寻找
***微信扫一扫,关注“python测试开发圈”,了解更多测试教程!***
Appium 自动化测试(8) -- Appium Python client -- API的更多相关文章
- Python+Appium自动化测试(1)-appium环境搭建
用python+appium做appUI自动化测试,系统为Windows.首先是JDK与Android SDK的安装与环境变量的设置. 一,安装JDK,配置JDK环境变量 1,下载jdk jdk8官网 ...
- Python+Appium自动化测试(2)-appium连接真机启动app
app自动化测试的第一步,是启动被测app.appium环境搭建好后,我们就可以连接真机启动app了.环境为windows,Appium1.18.0,Android手机,被测app为今日头条app,让 ...
- Python+Appium自动化测试(5)-appium元素定位常用方法
对于Android而言,查找appUI界面元素属性的工具有三种:appium desktop,uiautomatorviewer.bat,weditor.之前已经介绍过了weditor的使用,这里我将 ...
- appium自动化测试框架——在python脚本中执行dos命令
一般我们运行dos命令,会有两种需求,一种是需要收集执行结果,如ip.device等:一种是不需要收集结果,如杀死或开启某个服务. 对应的在python中就要封装两种方法,来分别实现这两种需求. 1. ...
- Appium自动化测试教程-自学网-monkeyrunner API
MonkeyRunner API MonkeyRunner工具主要有三个类: MonkeyRunner MonkeyDevice MonkeyImage 官方API文档 :http://www.and ...
- Appium 自动化测试(3)--Appium框架与流程介绍
Appium介绍 Appium是一个移动端的自动化框架,可用于测试原生应用,移动网页应用和混合型应用,且是跨平台的.可用于IOS和Android以及firefox的操作系统.原生的应用是指用andro ...
- Appium 自动化测试(7) -- Appium 服务器初始化参数设置
Desired Capabilities Desired capabilities 是一些发送给 Appium 服务器的键值对集合 (比如 map 或 hash),告诉服务器我们想要启动什么类型的自动 ...
- Python Client API文档
官网文档地址:http://docs.minio.org.cn/docs/master/python-client-api-reference 初使化MinIO Client对象 from minio ...
- Appium 自动化测试(5)-- Appium详细介绍:Appium 手机自动化测试_TesterHome公开版pdf
随机推荐
- 解决Android版Firefox字体显示过大的问题
在用Android版Firefox查看博客园首页发现中间区域的字体显示非常大,开始以为是首页css对移动版浏览器支持不好. 后来发现原来这是Firefox for Android的知名bug: Tha ...
- UIWebView中加载的网页尺寸太大,如何让网页适应屏幕大小 WebView加载HTML图片大小自适应与文章自动换行
webview.scalesPageToFit = YES; http://www.cnblogs.com/yujidewu/p/5740934.html 若需要根据图片原本大小,宽度小于320px的 ...
- kafka集群与zookeeper集群 配置过程
Kafka的集群配置一般有三种方法,即 (1)Single node – single broker集群: (2)Single node – multiple broker集群: (3)Mult ...
- rpc、socket、mq
关于RPC与MQ异同的理解 相同:1.都利于大型系统的解耦:2.都提供子系统之间的交互,特别是异构子系统(如java\node等不同开发语言):不同:1.RPC侧重功能调用,因此多半是同步的:备注:也 ...
- 9.GIt删除操作
在Git中,删除也是一个修改操作,我们实战一下,先添加一个新文件test.txt到Git并且提交: 创建一个文件test.txt,写入一句话`this is new file !`. $ echo ' ...
- JQuery的Ajax跨域请求的解决方式
今天在项目中须要做远程数据载入并渲染页面,直到开发阶段才意识到ajax跨域请求的问题,隐约记得Jquery有提过一个ajax跨域请求的解决方式,于是即刻翻出Jquery的API出来研究 ...
- LVM的一些问题汇总 tune2fs命令
LVM的一些问题汇总 tune2fs命令 --http://www.aminglinux.com/bbs/forum.php?mod=viewthread&tid=7664&page ...
- 002-spring cache 基于声明式注解的缓存-02-CachePut、CacheEvict、Caching、CacheConfig、EnableCaching、自定义
1.2.CachePut annotation 在支持Spring Cache的环境下,对于使用@Cacheable标注的方法,Spring在每次执行前都会检查Cache中是否存在相同key的缓存元素 ...
- Spring boot 集成ckeditor
1:下载ckeditor 4.4.2 full package ,官网没有显示, 需要在最新版本的ckeditor download右键,复制链接, 输入到导航栏,将版本号改为自己想要的版本号. h ...
- 嵌入式linux内核制作、根文件系统制作
嵌入式系统构成: 主要由bootloader.kernel.以及根文件系统三部分组成. 内核制作步骤: 制作嵌入式平台使用的linux内核制作方法与pc平台上的linux内核基本一致 1.清除原有配置 ...