2014-11-21 42 views
4

我正在測試Android 5.0的一些新功能,現在是UiAutomator的一輪以及實現的新方法。我試圖尋找一個例子/指南,然後我試圖通過如何獲取android.app.UiAutomation的實例

getSystemService() 

獲得UiAutomator的實例,但是這是沒有幫助的。我的目標是使用executeShellCommands(String str)

有沒有人已經實施?

+0

你能否重新說出你的問題,以便它能夠很好地理解你到底在找什麼? – 2014-11-22 19:53:09

+0

是的,請轉換爲不正確的詞組形式.. – 2014-11-23 00:06:59

回答

4

爲了澄清,UiAutomation類不是UiAutomator的一部分(儘管它們有相似的名稱)。

您可以通過調用 Instrumentation#getUiAutomation()來獲取UiAutomation實例。這隻適用於您正在運行基於Instrumentation的測試。

如果這是基於外殼的UiAutomator測試的一部分,那麼您可以使用Runtime#exec()執行shell命令。