运行case前,最好在case前加入等待,以免activity还未关闭,就开始定位或其他操作(如果case总报错,则考虑此问题);

swipe效果:

Thread.sleep(2000);

        int width = driver.manage().window().getSize().width;

        int height = driver.manage().window().getSize().height;

        driver.swipe(width * 3 / 4, height / 2, width / 4, height / 2, 500);

        Thread.sleep(1000);

        driver.swipe(width * 3 / 4, height / 2, width / 4, height / 2, 500);

实现输入中文的方法:

capabilities.setCapability("unicodeKeyboard", "True");

        capabilities.setCapability("resetKeyboard", "True");

xpath定位:

//相对定位

WebElement el = driver.findElement(By.xpath("//android.support.v7.widget.RecyclerView/child::android.widget.RelativeLayout/android.widget.TextView[1]"));



       //绝对定位

        WebElement element = driver.findElement(By.xpath("//android.widget.ImageButton[contains(@content-desc,'转到上一层级')]"));

       //相对定位

        WebElement element1 = driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'热门推荐')]/parent::android.widget.RelativeLayout/following-sibling::android.widget.FrameLayout[1]/"

                + "android.widget.RelativeLayout/child::android.widget.TextView[3]"));

自动化测试时,可以录制测试视频且保存在手机设备:

Runtime rt = Runtime.getRuntime();

        // this code for record the screen of your device

        rt.exec("cmd /C adb shell screenrecord /sdcard/test2.mp4");

Appium总结的更多相关文章

  1. Appium移动自动化框架

    引言:Appium 是一个移动端自动化测试开源工具,可以针对不同的平台用一套API来编写测试用例.本文对Appium自动化测试框架的功能进行了概括. 本文选自<软件自动化测试开发>. Ap ...

  2. appium+robotframework环境搭建

    appium+robotframework环境搭建步骤(Windows系统的appium自动化测试,只适用于测试安卓机:ios机需要在mac搭建appium环境后测试) 搭建步骤,共分为3部分: 一. ...

  3. Appium python API 总结

    Appium python api 根据testerhome的文章,再补充一些文章里面没有提及的API [TOC] [1]find element driver 的方法 注意:这几个方法只能通过sel ...

  4. Appium scroll 滑动查找

    首先看uiautomator如何实现滑动查找 UiScrollable scrollView = new UiScrollable(new UiSelector().className("a ...

  5. Appium+python的一个简单完整的用例

    最近一直在忙,终于有时间来整理一下,传一个简单的用例,运行之后可以看到用例的报告,希望对大家有帮助. HTMLTestRunner这个包网上有很多,大家可以自己下载. 1 import unittes ...

  6. Appium环境搭建+cordova

    1.安装JDK 配置JAVA_HOME(变量值为jdk的安装目录)以及Path path值如下: 验证是否生效 2.安装node.js 选择适合自己的版本官网直接下载https://nodejs.or ...

  7. Appium简单测试用例

    工程目录如下: 封装初始化androiddriver 方法 import org.openqa.selenium.remote.DesiredCapabilities; import java.io. ...

  8. appium常用方法整理

    1.相对坐标解锁九宫格 应用场景 QQ解锁屏幕如上,可见九个按键在同一个View下面,要实现解锁,用press   moveTo  release  perform方法 实现代码如下: WebElem ...

  9. appium 滑动

    前些日子,配置好了appium测试环境,至于环境怎么搭建,参考:http://www.cnblogs.com/tobecrazy/p/4562199.html   知乎Android客户端登陆:htt ...

  10. Appium 三种wait方法(appium 学习之改造轮子)

    前些日子,配置好了appium测试环境,至于环境怎么搭建,参考:http://www.cnblogs.com/tobecrazy/p/4562199.html   知乎Android客户端登陆:htt ...

随机推荐

  1. js-ES6学习笔记-Set结构和Map结构

    http://www.cnblogs.com/lonhon/ 1.ES6 提供了新的数据结构 Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set 本身是一个构造函数,用来生成 Set ...

  2. 关于标签中常用的disabled

    .children("option[disabled]").removeAttr('disabled');

  3. Java通过Axis2发布WebService

    参考文档: http://blog.csdn.net/ghsau/article/details/12714965 http://www.iteye.com/topic/1135747 http:// ...

  4. English - Titanium Bike

    The silver-gold triathlon bike was sitting in Kris's dining room next to the door. It had no kicksta ...

  5. C#字典转换成where条件

    where 1=1 and Dictionary[key1]=Dictionary[value1] and Dictionary[key2]=Dictionary[value3].... /// &l ...

  6. PHP面向对象 ——多态

    接口 接口(interface)是抽象方法和静态常量定义的集合. 接口是一种特殊的抽象类,这种抽象类中只包含抽象方法和静态常量. 接口中没有其它类型的内容 接口的定义 /** * 接口可以认为是特殊的 ...

  7. CJOJ 2040 【一本通】分组背包(动态规划)

    CJOJ 2040 [一本通]分组背包(动态规划) Description 一个旅行者有一个最多能用V公斤的背包,现在有n件物品,它们的重量分别是W1,W2,...,Wn,它们的价值分别为C1,C2, ...

  8. win10 运行sqlplus报错“SP2-1503: 无法初始化 Oracle 调用界面”

    解决方法: 1.临时方案:此时可以以“管理员身份”运行cmd,然后再执行sqlplus就行了. 长久方案: 请看原文:http://blog.csdn.net/bisal/article/detail ...

  9. 首页音乐播放器添加"多首音乐"

    添加音乐播放器可以去这个博主的网址参考学习 原文链接:http://www.cnblogs.com/RhinoC/p/4695509.html 以下是针对添加“多首音乐”的详细过程: (注:由于之前并 ...

  10. 修改User-Agent来伪装浏览器访问手机站点

    有时候为了测试需要,可能需要使用测试手机wap这样的站点,如果用真正的手机去测试也可以实现,但是比较麻烦,我们可以通过设置chrome的user agent来伪装浏览器,达到我们的测试目的. 代码如下 ...