{"record":{"id":"6126bb0b5157ce37","repo":"SeleniumHQ/selenium","slug":"behavior-can-only-be-one-of-the-following-dismiss","errorCode":null,"errorMessage":"Behavior can only be one of the following: dismiss, accept, dismiss and notify, accept and notify, ignore","messagePattern":"Behavior can only be one of the following: dismiss, accept, dismiss and notify, accept and notify, ignore","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/options.py","lineNumber":112,"sourceCode":"\n    Args:\n        behavior: behavior to use when an alert is encountered\n\n    Returns:\n        Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)\n    \"\"\"\n\n    def __init__(self, name):\n        self.name = name\n\n    def __get__(self, obj, cls):\n        return obj._caps.get(self.name)\n\n    def __set__(self, obj, value):\n        if value in (\"dismiss\", \"accept\", \"dismiss and notify\", \"accept and notify\", \"ignore\"):\n            obj.set_capability(self.name, value)\n        else:\n            raise ValueError(\n                \"Behavior can only be one of the following: dismiss, accept, dismiss and notify, \"\n                \"accept and notify, ignore\"\n            )\n\n\nclass _TimeoutsDescriptor:\n    \"\"\"How long the driver should wait for actions to complete before returning an error.\n\n    See:\n      - https://w3c.github.io/webdriver/#timeouts\n\n    Args:\n        timeouts: values in milliseconds for implicit wait, page load and script timeout\n\n    Returns:\n        Values for implicit timeout, pageLoad timeout and script timeout if set (in milliseconds)\n    \"\"\"\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/options.py#L94-L130","documentation":"The unhandled_prompt_behavior property validates against the W3C-defined alert-handling behaviors: 'dismiss', 'accept', 'dismiss and notify', 'accept and notify', and 'ignore'. Any other value raises ValueError. Note the values are lowercase, space-separated, using 'and' (not '&').","triggerScenarios":"Setting options.unhandled_prompt_behavior to a value not in the allowed set, e.g. 'dismiss_and_notify', 'Accept', 'accept-and-notify', 'accept & notify', or 'default'.","commonSituations":"Using underscores instead of spaces ('dismiss_and_notify'). Using ampersands ('accept & notify'). Wrong casing. Confusing with a different driver's prompt-behavior vocabulary.","solutions":["Use one of the exact lowercase strings with spaces: 'dismiss', 'accept', 'dismiss and notify', 'accept and notify', 'ignore'.","Replace underscores with spaces and use 'and' not '&'."],"exampleFix":"# before\noptions.unhandled_prompt_behavior = 'dismiss_and_notify'  # raises\n\n# after\noptions.unhandled_prompt_behavior = 'dismiss and notify'","handlingStrategy":"validation","validationCode":"ALLOWED = {'dismiss','accept','dismiss and notify','accept and notify','ignore'}\nif behavior not in ALLOWED:\n    raise ValueError(f'Invalid unhandled_prompt_behavior {behavior!r}')\noptions.unhandled_prompt_behavior = behavior","typeGuard":"ALLOWED = {'dismiss','accept','dismiss and notify','accept and notify','ignore'}\ndef is_valid_prompt_behavior(v: str) -> bool:\n    return v in ALLOWED","tryCatchPattern":"try:\n    options.unhandled_prompt_behavior = behavior\nexcept ValueError:\n    options.unhandled_prompt_behavior = 'dismiss and notify'","preventionTips":["Remember values use spaces and 'and', not underscores or '&'.","Validate against the constant set before assignment."],"tags":["options","unhandled-prompt","validation","capabilities"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}