def test_access_alerts_using_with(browser, app_url):
    "should access alerts using 'with' statement"
    browser.visit(app_url + "alert")
    browser.find_by_tag("h1").click()
    with browser.get_alert() as alert:
        assert "This is an alert example." == alert.text
        alert.accept()
should access alerts using 'with' statement
tests/tests_webdriver/test_alerts.py