簡體   English   中英

Android:uiautomator中的外部文件

[英]Android: External file in uiautomator

我已經使用uiautomator在Java中為Android開發了mobile automation project

我已經按照以下所有步驟操作:-

  1. 創建罐子
  2. 將罐子推到設備
  3. 最后運行測試用例

我需要使用user namepassword自動執行登錄功能。 我已經創建了excel文件來讀取用戶名和密碼(如selenium

但是當我訪問此Excel文件時,它給出了File Not Found的異常。

adb shell uiautomator runtest /sdcard/myApp.jar -c com.example.LoginTest

有什么辦法可以在uiautomator中訪問其他文件?

UIAutomator作為一個進程在shell運行,因此我們將無法訪問在PC中運行的excel文件

但是,有兩種方法可以使其自動化:

1,編寫一個腳本來解析excel工作表並將其設置為虛擬系統屬性,使用UIAutomator讀取相同的內容

//set android dummy property using script
adb shell setprop dummy value 

//Read Value of property in UIAutomator
getProperty("dummy");

//Subroutine for Reading Property from Android
public String getProperty(String propName) {
String propValue = null;
try {
propValue = (String) Class.forName("android.os.SystemProperties").getMethod("get", new Class[] { String.class }).invoke(null, propName);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return propValue;
}

2,將值寫入文本文件並在Java中使用UIAutomator類進行解析

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM