Ignore Alert

Ignore alert #

ignoreAlert();

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

The method has no effect if no alert is opened.

public void testUIWithLoadero() {
    // Example of ignore alert
    open("http://www.google.com");
    E(byCssSelector("input[title='Search']")).waitFor(10).untilIsVisible();

    executeJs("prompt('prompt!')");
    ignoreAlert();
    E(byCssSelector("input[title='Search']")).saveScreenshot("screenshot.png");
}
A typical use case, as shown in the example, is to close an alert if there is one before taking a screenshot.