![](/img/trans.png)
[英]UIautomator - Android Studio - How to generate an APK or JAR file
[英]Android: External file in uiautomator
我已經使用uiautomator在Java中為Android開發了mobile automation project
。
我已經按照以下所有步驟操作:-
我需要使用user name
和password
自動執行登錄功能。 我已經創建了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.