SeleniumHQ/selenium · error · ValueError
Event '{event}' not found. Available events: {self._availabl
Error message
Event '{event}' not found. Available events: {self._available_events} What it means
Raised as a ValueError by _EventManager.validate_event() when the event name passed to it is not a key in the event_configs dictionary. The manager holds a registry of supported events (built from EventConfig entries) and computes _available_events as a sorted, comma-joined string for the error message. Calling validate_event with an unregistered event name is a usage error indicating the event is not part of this BiDi module's supported event set.
Source
Thrown at py/private/_event_manager.py:109
def __init__(self, conn, event_configs: dict[str, EventConfig]):
self.conn = conn
self.event_configs = event_configs
self.subscriptions: dict = {}
self._event_wrappers = {} # Cache of _EventWrapper objects
self._bidi_to_class = {config.bidi_event: config.event_class for config in event_configs.values()}
self._available_events = ", ".join(sorted(event_configs.keys()))
self._subscription_lock = threading.Lock()
# Create event wrappers for each event
for config in event_configs.values():
wrapper = _EventWrapper(config.bidi_event, config.event_class)
self._event_wrappers[config.bidi_event] = wrapper
def validate_event(self, event: str) -> EventConfig:
event_config = self.event_configs.get(event)
if not event_config:
raise ValueError(f"Event '{event}' not found. Available events: {self._available_events}")
return event_config
def subscribe_to_event(self, bidi_event: str, contexts: list[str] | None = None) -> None:
"""Subscribe to a BiDi event if not already subscribed."""
with self._subscription_lock:
if bidi_event not in self.subscriptions:
session = Session(self.conn)
result = session.subscribe([bidi_event], contexts=contexts)
sub_id = result.get("subscription") if isinstance(result, dict) else None
self.subscriptions[bidi_event] = {
"callbacks": [],
"subscription_id": sub_id,
}
def unsubscribe_from_event(self, bidi_event: str) -> None:
"""Unsubscribe from a BiDi event if no more callbacks exist."""
with self._subscription_lock:
entry = self.subscriptions.get(bidi_event)View on GitHub (pinned to aa36b38e69)
Solutions
- Read the 'Available events' portion of the error message — it lists the exact valid event names for this module.
- Copy the exact event name string from the available events list into your code to avoid spelling or casing mismatches.
- Confirm you are calling the method on the correct BiDi module (e.g. network events on the network module, log events on the log module).
- Check the Selenium version's API docs for renamed or newly added events if upgrading.
Example fix
# before
manager.validate_event('responceStarted') # typo
# after
manager.validate_event('responseStarted') # from available events list Defensive patterns
Strategy: validation
Validate before calling
# Validate before calling
valid_events = set(manager.event_configs.keys())
if event_name not in valid_events:
raise ValueError(f'Use one of: {sorted(valid_events)}')
manager.validate_event(event_name) Try / catch
try:
manager.validate_event(event_name)
except ValueError as e:
if 'not found' in str(e):
# read available events from the message and correct
pass
else:
raise Prevention
- Read the Available events list from the error message for valid names.
- Use constants or enums for event names rather than string literals to avoid typos.
- Confirm the event belongs to the correct BiDi module.
When it happens
Trigger: Calling an event-validation entry point (e.g. add_event_listener or callback registration on a generated BiDi module) with an event string that does not match any key in that module's event_configs. The message includes the sorted list of valid event names for diagnostics.
Common situations: Misspelling an event name (e.g. 'responceStarted' instead of 'responseStarted'); using an event name from a different BiDi module than the one being called; version mismatch where an event was renamed in a newer Selenium release; mixing up camelCase vs snake_case event identifiers.
Related errors
- {self._label.capitalize()} '{handler_id}' not found
- Extra header '{name}' not found
- Unsupported DOM mutation type(s) {sorted(unknown)}; expected
- mutation_types must name at least one mutation type
- interval must be a positive number
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/977affd2e0caf3f9.
Report an issue: GitHub.