現在表示されているJavaScriptのalert()、confirm()、またはprompt()ダイアログのテキストを取得します。

使い方

                    .alerts.getText([callback])
                

module.exports = {
  'get open alert text': function (browser) {
    browser
      .alerts.getText(function (result) {
        console.log('text on open alert:', result.value);
      });
  },

  'get open alert text with ES6 async/await': async function (browser) {
    const alertText = await browser.alerts.getText();
    console.log('text on open alert:', alertText);
  }
};

パラメータ

名前 説明
callback
オプション
function

結果の値とともに呼び出されるコールバック関数。

戻り値

説明
string

現在表示されているアラートのテキスト。

参考

W3C WebDriver仕様