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://google.com')
.waitForElementVisible('input[title="Search"]', 10000)
.execute(function () {
prompt('prompt!');
})
.ignoreAlert()
.takeScreenshot('screenshot.png');
}
A typical use case, as shown in the example, is to close an alert before taking a screenshot.