Ignore Alert

Ignore Alert #

def ignore_alert(driver: TestUIDriver) -> None

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

The function has no effect if no alert is opened.

def test(driver):
    # Example of ignore alert function
    driver.navigate_to("https://www.google.com/")
    e(driver, "css", 'input[title="Search"]').wait_until_visible(seconds=10)
    driver.execute_script("prompt('prompt!');", None)
    ignore_alert(driver)
    driver.save_screenshot("screenshot.png")
A typical use case, as shown in the example, is to close an alert if there is one before taking a screenshot.