3

アラートに [はい] ボタンと [いいえ] ボタンがある場合に、アラート メッセージ ボタンをクリックする方法。

そして、私は次のような方法を試しました:

target.frontMostApp().alert().buttons()["buttonName"].tap();
target.frontMostApp().alert().buttons()["index"].tap();

また、Ui オートメーションはいずれかのボタンをクリックし、以下の構文税を次のように表示します。

target.frontMostApp().alert().cancelButtons().tap();

デフォルトのボタンをクリックするために手動で行っても機能しませんでした。また、以下の方法でも試しました。

target.frontMostApp().alert().cancelButtons()["index/buttonname"].tap();
target.frontMostApp().alert().defaultButtons()["index/buttonname"].tap();

アラート メッセージから [はい] ボタンまたは [いいえ] ボタンを選択するにはどうすればよいですか?

4

1 に答える 1

1

ああ、onAlert 内でこのコードを使用する必要があります。

また、try catch ブロックで 2 回目のタップが必要です。

テーブル内の行を削除し、削除ボタンに表示されるアラートを確認するために使用される私のコード。

target.frontMostApp().mainWindow() .tableViews()["Empty list"].cells()[0]
  .dragInsideWithOptions({startOffset:{x:0.03, y:0.44}, 
  endOffset:{x:0.81, y:0.50},duration:1}); 

target.frontMostApp().mainWindow().tableViews()["Empty list"].cells()[0]
  .buttons()[0].tap();


UIATarget.onAlert = function onAlert(alert) {
    alert.tapWithOptions({tapOffset:{x:0.73, y:0.72}});
}

try {
    target.frontMostApp().alert().tapWithOptions({tapOffset:{x:0.72, y:0.78}});
}
catch (ex) {}
于 2012-11-08T13:42:39.873 に答える