1. 程式人生 > >Uiautomator向jar包傳多個引數

Uiautomator向jar包傳多個引數

先看uiautomator的命令解析,隨便輸了個uiautomator -help,讓其顯示用法,打印出來的資訊如下:

——————————————————————————————————————————————————————————————

[email protected]:/ $ uiautomator -help

uiautomator -help
Usage: uiautomator <subcommand> [options]


Available subcommands:


help: displays help message


runtest: executes UI automation tests
    runtest <class spec> [options]
    <class spec>: <JARS> < -c <CLASSES> | -e class <CLASSES> >
      <JARS>: a list of jar files containing test classes and dependencies. If
        the path is relative, it's assumed to be under /data/local/tmp. Use
        absolute path if the file is elsewhere. Multiple files can be
        specified, separated by space.
      <CLASSES>: a list of test class names to run, separated by comma. To
        a single method, use TestClass#testMethod format. The -e or -c option
        may be repeated. This option is not required and if not provided then
        all the tests in provided jars will be run automatically.
    options:
      --nohup: trap SIG_HUP, so test won't terminate even if parent process
               is terminated, e.g. USB is disconnected.
      -e debug [true|false]: wait for debugger to connect before starting.
      -e runner [CLASS]: use specified test runner class instead. If
        unspecified, framework default runner will be used.
      -e <NAME> <VALUE>: other name-value pairs to be passed to test classes.
        May be repeated.

      -e outputFormat simple | -s: enabled less verbose JUnit style output.


dump: creates an XML dump of current UI hierarchy
    dump [--verbose][file]
      [--compressed]: dumps compressed layout information.
      [file]: the location where the dumped XML should be stored, default is
      /storage/emulated/legacy/window_dump.xml


events: prints out accessibility events until terminated

————————————————————————————————————————————————————————————————————

上面紅色文字部分,即使解釋如何傳參,下面用一個例子說明其用法:

假設我需要想jar包穿三個引數,String uiserName,String password,long runTime,則對應的命令應該如下:

uiautomator runtest TestLogin.jar -e userName CrystalChen -e runTime 1000000 -e password 123 --nohup -c com.example.TestLogin

下劃線斜體部分則為對應的引數配置。

在你的UiautomatorTestCase中對應接受引數的地方應該書寫如下:

public void test1() throws Exception {
		Bundle bundle=getParams();//獲取鍵值對
		String userName=bundle.getString("userName");
		String password=bundle.getString("password");
		long runTime=Long.parseLong(bundle.getString("runTime"));
		System.out.println(runTime+"======="+password+"========"+userName);
	}

注意:非String型別的引數不能通過bundle.getLong這種方法獲取,這樣是獲取不到的,這些鍵值對必須通過getString來獲取,然後對應轉化成你要的型別。

相關推薦

Uiautomatorjar引數

先看uiautomator的命令解析,隨便輸了個uiautomator -help,讓其顯示用法,打印出來的資訊如下: —————————————————————————————————————————————————————————————— [email pr

Daomapper引數(Mybatis)

第一種方案 DAO層的函式方法 : Public User selectUser(String name,String age); 對應的Mapper.xml <select id="selectUser" resultMap="BaseResultMap"

從onclick到function到ajax的url問號引數(更的話以此類推)問題

廢話不多直接上程式碼 onclick <a class="blue" onclick="changeUse('${use.device_code}','${use.device_use }');" href="javascript:void(0)" data-rel="tooltip

mybatis引數(不使用@param註解情況下),3.4.2版本之後出現#{0}-#{n}引數繫結異常

解決方案:        在mybatis配置檔案中宣告setting屬性的useActualParamName 引數值為false                   **

關於超連結引數其中URL 中的帶 {xxx}的問題,

window.location.href=basePath+"/weixin/car/paysuccess/"+wid+"?returnMSG="+returnMSG;    @RequestMapping(value = { "/paysuccess/{wid}" },

mybatis collection和association 引數

mybatis3.0版本以上,才可以 <resultMap type="CaseVO" id="processInfoList"> <id column="TEMPLATE_ID" property="taskTemplate.templ

關於Ajax引數的問題

最近都要自學程式碼了,上學不好好上,現在只能自己動手豐衣足食了 最近碰到的是關於頁面區域性更新,直接貼程式碼吧! 首先講一下傳單個引數吧 單個比較簡單,直接如下data寫法就好 //區域性更新 function up(ind){ var u

django URL的補充 預設值 引數

      url 後面還可以加上預設值 預設值 url(r'^index/', views.index, {'name': 'root'}),   urls.py url對應關係 from django.conf.urls import url

iview Select元件引數

問題描述:on-change 事件預設返回的是value值,想要多傳一個引數 解決辦法: <Select v-model="model1" @on-change="handleChange($event, 'params')"></Select

關於a標籤追加引數問題解決方案

相信在開發的過程中會遇到:通過 a標籤 傳引數的問題(一個或多個),不囉嗦了,直接上程式碼 這是我在做某一個功能是定義的一個 a 標籤,需要傳多個引數 view程式碼 <a href="" id="linkToCart" class="btn">這是我們在做某一個功能&l

在當java有jar檔案時,如何在控制檯編譯執行

編譯 javac -cp .:/root/java/hash2/lib/mysql-connector-java-5.1.35-bin.jar:/root/java/hash2/lib/c3p0-0.9.1.1.jar *.java   執行 java -cp .:

angular-ng-click用於操作事件的指令(引數

<!DOCTYPE html> <html ng-app="myApp"> <head>     <meta charset="UTF-8">     <title>Title</title>     <script src="js

SpringMVC頁面向Controller提交陣列+Mybatis引數+MySQL一次寫入條記錄

DAO層定義:int insertRole2Authorities(@Param("roleId")int roleId, @Param("authorities")List<Integer&g

linux c 執行緒引數

給新開啟的執行緒傳遞多個引數用結構體 struct Arges{     char topic[64];     char msg[64];     int len; }; int countThreat=0; void *text3(

performSelector引數

1.引數包裝成字典 2.自己實現對應方法 使用NSMethodSignure,NSInvoation - (id)performSelector:(SEL)aSelector withObjects:(NSArray *)arguments{ //1.根據S

mybatis引數(不使用@param註解情況下),3.4.2版本之後使用#{0}-#{n}引起的引數繫結異常,以及settings屬性中useActualParamName的作用。

解決方案: mybatis的xml配置檔案中宣告settings屬性的useActualParamName引數值為false <setting name="useActualParamName" value="false" /> 程式碼展示

Mybatis引數

三種方法 第一種: DAO層方法 Public User selectUser(String name,String area); 對應的Mapper.xml <select id="selectUser" resultMap="Bas

引數到後臺

後臺  @RequestMapping("/getdzlx")     public @ItemResponseBody QueryResultObject getdzlx(@RequestBody Map<String,Object> params) 前臺程式

MyBatis引數的常用方法

MyBatis傳多個引數的時候有很多種方法,這裡記錄一下自己常用的方法。 1、@Param註解。 Mapper.java介面: int get***ByContentIdAndClassId(@Param("contentId")String contentId, @P

onclick引數,為什麼函式接收不到,一個引數可以的問題做一個總結

今天遇到js onclick傳兩個引數 函式接收不到,如果onclick事件裡的值是死值傳多少個都沒問題,一個活參也沒問題,問題是多個活參就不可以;還是老規矩先上圖錯誤的傳參方式:如果是這樣傳參的同學及時糾正正確的傳參方式:在這時使用反斜槓進行了轉義,如果你是使用的超連結就須