macaca
来源:互联网 发布:apache ab post请求 编辑:程序博客网 时间:2024/06/04 19:10
环境配置参考官方文档https://macacajs.github.io/zh/environment-setup
启动服务器
# 普通用法,添加了 --verbose 可以看到详细的信息$ macaca server --verbose# 设置端口号$ macaca server -p 3456
检查当前 Macaca 的安装环境
$ macaca doctor
元素查看器
安装
$ npm i app-inspector -g
用法
# 直接 -u + 设备的 udid 即可$ app-inspector -u xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
测试代码
[python]from macaca import WebDriverimport timeserver_url = { 'hostname': '127.0.0.1', 'port': 3456}desired_caps = { 'platformName': 'Android', # iOS, Android. 'deviceName': '69T7N1622*******', 'platformVersion': '5.1.1', 'reuse': '3',#0: 启动并安装 app。1 (默认): 卸载并重装 app。 2: 仅重装 app。3: 在测试结束后保持 app 状态。 'package':'com.tencent.mm',#微信 #'activity':'com.tencent.mm.ui.LauncherUI'}driver = WebDriver(desired_caps,server_url)driver.init()#需要登录密码时使用#driver.wait_for_element('xpath','//*[@resource-id="com.tencent.mm:id/bfn"]',timeout=60).send_keys("keys")#driver.wait_for_element('xpath','//*[@resource-id="com.tencent.mm:id/bfo"]',timeout=60).touch('tap')driver.touch('tap', { 'x': 637, 'y': 1638})#根据坐标值定位元素driver.wait_for_element('xpath','//*[@text="朋友圈"]',timeout=60).touch('tap')#根据xpath定位元素text=driver.source#获取文本print(text)#拖动10次for i in range(10): driver.touch('drag', { 'fromX': 530, 'fromY': 1700, 'toX': 800, 'toY': 300, 'duration': 1}) time.sleep(random.uniform(12, 16))def switch_to_webview(): contexts = self.driver.contexts driver.context = contexts[-1] return driverdef switch_to_native(self): contexts = self.driver.contexts self.driver.context = contexts[0] return driver
参考 Macaca 自动化框架 [Python 系列]
阅读全文
0 0
- macaca
- macaca
- Macaca之常见参数
- Macaca之uirecorder使用
- 安装Macaca,打不开问题
- Macaca基础原理
- Macaca Inspector启动命令
- Macaca自动化测试框架
- macaca之zfb
- Macaca Macaca 实现 IOS Monkey 测试 (支持 macaca2.x 版本)
- Macaca 实现 iosMonkey (python 版)
- macaca app-inspector环境搭建
- macaca 测试web(3)
- macaca 测试web(3)
- Macaca 实现 iosMonkey (python 版)
- Macaca自动化测试Android和IOS应用
- ios Monkey 的Macaca实现,Java代码
- Macaca之App Inspector使用简介
- 位运算基础
- 借助国内镜像库安装docker镜像
- JS 大坑 之 0.1+0.2 计算精度的问题
- tinyxml和tinyxml
- mac 相对布局
- macaca
- 颜色设置值
- SpringBoot
- NC57在前台,如何通过表头VO得到表体VO或者聚合的也行?
- tomcat 启动动重复Multiple Contexts have a path of "/xxxx"问题解决
- c++实现单/双链表
- vue 组件
- 【Maven+SSM】补充:写一个数据和对象Binding请求
- tensorflow安装以及linux下IDE的搭建