2012年08月25日
UIAutomationの操作記録 @ Mac
以前試した時には無かったと思うのですが、いつの間にか、Instrumentsで、UIAutomationの操作記録が出来る様になっていたんですね。
Instrumentsで、Automationを選択して起動し、スクリプトを追加して、記録ボタンを押して、アプリを色々操作すると以下の様な内容が記録されます。
var target = UIATarget.localTarget();
target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["1-3"].scrollToVisible();
target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["1-3"].scrollToVisible();
target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["0-1"].tap();
// Alert detected. Expressions for handling alerts should be moved into the UIATarget.onAlert function definition.
target.frontMostApp().alert().defaultButton().tap();
target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["1-1"].scrollToVisible();
target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()["3-1"].tap();
// Alert detected. Expressions for handling alerts should be moved into the UIATarget.onAlert function definition.
target.frontMostApp().alert().buttons()["OK"].tap();
しかし、記録直後だとそのまま再生しても動きません。不完全な状態なので、下向き三角の付いた箇所をダブルクリックして確定し、"Empty list"の様に存在しない部分を修正して、コメントに書かれてあるAlert部分も書き換えれば無事動きました。
最後の
target.frontMostApp().alert().buttons()["OK"].tap();
この辺は
UIATarget.onAlert = function onAlert(alert) {
target.frontMostApp().alert().buttons()["OK"].tap();
}
target.delay(2.0);
こんな感じに書き換えました。
ゼロから書くとなると、最初は敷居が高いかなと思いましたが、多少なりとも補助してくれるだけマシかな。Xcodeでスクリプトを編集すれば、完全ではなさそうだけど、保管も効くので、使えると言えば使えるかな。
関連日記
- 2010年12月27日 UIAutomation (1930)@ 携帯電話
アマゾン広告
この日記ページは閲覧数などの条件に応じて、閲覧制限を行っています。他からリンクしていただいても、そのリンクから辿った閲覧者が当ページの内容をご覧頂けない場合があります。ご了承下さい。