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.bing.com/")
    e(driver, "css", '[type=search]').wait_until_visible()
    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.