Sutune

静心成大器,稳定动乾坤

0%

应用背景

在app应用日常使用过程中,会经常用到在屏幕滑动操作。如刷朋友圈上下滑操作、浏览图片左右滑动操作等。在自动化脚本该如何实现这些操作呢?

在Appium中模拟用户滑动操作需要使用swipe方法,该方法定义如下:

1
2
3
4
5
6
7
8
9
10
11
12
def swipe(self, start_x, start_y, end_x, end_y, duration=None):
"""Swipe from one point to another point, for an optional duration.

:Args:
- start_x - x-coordinate at which to start
- start_y - y-coordinate at which to start
- end_x - x-coordinate at which to stop
- end_y - y-coordinate at which to stop
- duration - (optional) time to take the swipe, in ms.

:Usage:
driver.swipe(100, 100, 100, 400)
阅读全文 »

问题思考

在混合开发的App中,经常会有内嵌的H5页面。那么这些H5页面元素该如何进行定位操作呢?

解决思路

针对这种场景直接使用前面所讲的方法来进行定位是行不通的,因为前面的都是基于Andriod原生控件进行元素定位,而Web网页是单独的B/S架构,两者的运行环境不同因此需要进行上下文(context)切换,然后对H5页面元素进行定位操作。

阅读全文 »

问题思考

在日常使用App过程中,经常会看到App界面有一些弹窗提示(如下图所示)这些提示元素出现后等待3秒左右就会自动消失,那么我们该如何获取这些元素文字内容呢?

Toast

阅读全文 »

元素定位

与Web自动化测试一样,app自动化测试过程中最重要一个环节就是元素定位,只有准确定位到了元素才能进行相关元素的操作,如输入、点击、拖拽、滑动等。appium提供了许多元素定位的方法,如id定位、name定位、class定位、层级定位等等…. 接下来将会给大家来实践运用这些定位技巧。

阅读全文 »

Android 调试桥

adb ( Android Debug Bridge)是一个通用命令行工具,其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利,如安装和调试应用。

Tips:
在 android_sdk/platform-tools/ 中找到 adb 工具,然后根据其具体的路径配置好环境变量。然后启动cmd 输入‘adb’即可查看是否配置成功。

阅读全文 »

什么是Capability

desired capability的功能是配置Appium会话。他们告诉Appium服务器您想要自动化的平台和应用程序。

Desired Capabilities是一组设置的键值对的集合,其中键对应设置的名称,而值对应设置的值。(如:”platformName”: “Android”)Desired Capabilities主要用于通知Appium服务器建立需要的Session。

阅读全文 »

环境依赖

  • Node.js
  • Appium
  • Appium-desktop
  • Appium-doctor
  • Appium-Python-Client
  • Python
  • JDK
  • Andriod SDK

以上所需的软件本套教程素材包都提供,可以在视频左下角【获取素材】去对应章节下载,找到Appium环境配置全家桶

阅读全文 »