Skip to main content

Ignore Alert

client.ignoreAlert();

Command will close alert opened by alert(), prompt() or confirm() JavaScript functions.

Calling command on a non-existent alert will log an error but not fail the test.

client => {
client
// Example of closing alert before taking a screenshot
.url('https://www.bing.com')
.waitForElementVisible('[type=search]', 10000)
.execute(function () {
prompt('prompt!');
})
.ignoreAlert()
.takeScreenshot('screenshot.png');
}
info

A typical use case, as shown in the example, is to close an alert before taking a screenshot.