# UnexpectedAlertPresentException (Selenium)

Source: https://www.observeone.com/community/errors/selenium/unexpected-alert

[ObserveOne](/)[Features](/#features)[Pricing](/#pricing)[Blog](/blog)[CLI](/cli)[Docs](/docs)

[Sign in](https://app.observeone.com/auth?tab=signin)[Start Free](https://app.observeone.com/auth?tab=signup)

[Error Dictionary](/community/errors)/[Selenium](/community/errors/selenium)/unexpected-alertmedium

# UnexpectedAlertPresentException

A JavaScript alert, confirm, or prompt dialog appeared unexpectedly, blocking automation. Selenium cannot interact with the page until the alert is dismissed.

## Common Causes

- 1Application shows a confirm dialog before navigation
- 2JavaScript error triggered an alert
- 3Form submission shows a validation alert
- 4Session timeout alert appeared

## How to Fix

### Handle the alert explicitly

// Python
from selenium.webdriver.common.alert import Alert

alert = Alert(driver)
print(alert.text) # Read alert text
alert.accept() # Click OK
# or
alert.dismiss() # Click CancelUse the Alert class to inspect and handle JavaScript dialogs.

### Set unexpected alert behavior in capabilities

// Python
from selenium.webdriver.chrome.options import Options

options = Options()
options.set_capability('unhandledPromptBehavior', 'accept')
driver = webdriver.Chrome(options=options)Automatically accept all alerts. Useful when you don't care about alert content.

## How ObserveOne Helps

ObserveOne monitors browser dialogs and handles unexpected alerts automatically during test execution.

[Start Monitoring Free](https://app.observeone.com/auth?tab=signup)

## Related Errors

[ElementNotInteractableExceptionThe element exists in the DOM but cannot be interacted with. It may be hidden, disabled, or covered by another element.](/community/errors/selenium/element-not-interactable)[StaleElementReferenceExceptionThe element previously located is no longer attached to the DOM. The page was refreshed, navigated, or the element was re-rendered by JavaScript.](/community/errors/selenium/stale-element-reference)[NoSuchElementExceptionNo element matching the locator strategy could be found in the current page DOM. The element may not exist, may not have loaded yet, or the locator may be incorrect.](/community/errors/selenium/no-such-element)[ElementClickInterceptedExceptionThe click command could not be completed because another element would receive the click at the target coordinates. A different element is covering the target.](/community/errors/selenium/element-click-intercepted)[SessionNotCreatedException: Could not start a new sessionWebDriver could not create a new browser session. Usually caused by a version mismatch between the browser and the driver.](/community/errors/selenium/session-not-created)

ObserveOne

Agentic QA and synthetic monitoring built for engineering teams. Plan, generate, and run suites from the web UI. Connect to CI for reliable coverage across critical journeys.

### Product

- [Features](/#features)
- [Pricing](/#pricing)
- [QA Coverage](/qa-coverage)
- [API Monitoring](/api-monitoring)
- [Free Website Check](/free-website-check)

### Developers

- [CLI](/cli)
- [Docs](/docs)
- [For Agents](/agents)
- [Self-host (oo-workers)](/workers)
- [Status Pages](/status)
- [Netlify Extension](https://app.netlify.com/extensions/mzs1lgc3-observeone)

### Resources

- [Blog](/blog)
- [Bug Book](/bug-book)
- [Guides](/community/guides)
- [Tools](/community/tools)
- [Error Dictionary](/community/errors)

### Compare

- [Tool Comparisons](/compare)
- [Tool Alternatives](/alternatives)
- [Best by Category](/best)
- [Search](/search)

© 2026 ObserveOne. All rights reserved.

[About](/about)[Privacy Policy](/privacy)[Terms of Service](/terms)[Affiliates](/affiliates)[Become an Affiliate](/affiliate-terms)
