Android-Uiautomator:[6]运行中传入参数

来源:互联网 发布:淘宝女装,连衣裙 编辑:程序博客网 时间:2024/04/30 19:13

测试中有些可变参数如何,根据不同的情况,传入到脚本中呢

uiautomator是有提供传入的办法的

工具/原料

  • 参数:-e <NAME> <VALUE>

方法/步骤

  1. -e 后面跟着一对bundle键值对

    如:我要传入一个电话号码,让脚本拨打指定的号码

    publicclassDialSuiteextendsLenovoUiTestCase{

        privateStringphoneNumber="10086";//默认拨打10086

    publicvoidtestDemo(){

    Bundlephone=getParams();//获取键值对

    if(phone.getString("phone")!=null){

    phoneNumber=phone.getString(“phone”);//安装键值提取电话号码

    }

    dial(phoneNumber);//拨打指定电话号码

    }}

  2. 2

    编译完后,我们可以用如下命令进行运行,传入参数,让手机拨打18888888888

    adb shell uiautomator runtest test.jar –e phone 18888888888 -c com.demo.DialSuite

  3. 转自:http://jingyan.baidu.com/article/ca2d939d2a88b2eb6c31cef3.html

0 0
原创粉丝点击