私はiPhone用のUITestingを試していますが、スタンフォード大学のcs193p iTunes Uクラスの講義2の簡単なrpn計算機を使用して、最初のテストを実行すると思いました。
私のJavaScriptは次のとおりです
var target = UIATarget.localTarget();
target.frontMostApp().mainWindow().buttons()["3"].tap();
target.frontMostApp().mainWindow().buttons()["Enter"].tap();
target.frontMostApp().mainWindow().buttons()["4"].tap();
target.frontMostApp().mainWindow().buttons()["/"].tap();
var display = target.frontMostApp().mainWindow().staticTexts()[1].value();
if (display == "0.75") {
UIALogger.logPass("3 E 4 /");
} else {
UIALogger.logFail("3 E 4 /");
}
ただし、スクリプトはsin entercosを実行します/エディターログに表示されます
target.frontMostApp().mainWindow().buttons()[3].tap();
target.frontMostApp().mainWindow().buttons()["Enter"].tap();
target.frontMostApp().mainWindow().buttons()[4].tap();
target.frontMostApp().mainWindow().buttons()["/"].tap();
どういうわけか、楽器は私の文字列「3」をインデックス3に変換してから、3番目のボタンをタップしています。
そのため、ボタンをインデックス番号で呼び出すこともできますが、テキストで呼び出す方がはるかに好きです。