天天看點

UIAutomation: 通過指令行運作測試用例

為了實作自動定時的運作腳本,我們需要在指令行運作和啟動腳本,具體代碼如下:

instruments -t /applications/xcode.app/contents/applications/instruments.app/contents/plugins/automationinstrument.bundle/contents/resources/automation.tracetemplate

<full_path_to_application>

-e uiascript <path_to_script.js>

-e uiaresultspath <output_results_path>

  1.  -t 後面的參數為 automation.tracetemplate 的路徑,每個版本的位置都有所不同,在指令行下使用 instruments -s 指令進行查詢。

  2.  full_path_to_application 是你的的被測應用的完整目錄,需要在前後加上雙引号。

  3.  -e uiascript  指定執行的 js 腳本存放的位置,需要在前後加上雙引号。

  4.  -e uiaresultpath  指定輸出結果存放的路徑,需要在前後加上雙引号。

  舉例在我本地模拟器上的腳本如下:

instruments -t

/applications/xcode.app/contents/applications/instruments.app/contents/plugins/automationinstrument.bundle/contents/resources/automation.tracetemplate

"/users/wangxinxin/library/developer/xcode/deriveddata/testautomation-ahmqgmqipyidexemazbprqxqkrya/build/products/debug-iphonesimulator/testautomation.app"

-e uiascript "/users/wangxinxin/documents/testautomation/test.js"

-e uiaresultspath "/users/wangxinxin/documents/testautomation"

最新内容請見作者的github頁:http://qaseven.github.io/

繼續閱讀