SeleniumHQ/selenium · error · WebDriverException
Value of a session permission must be set to True or False.
Error message
Value of a session permission must be set to True or False.
What it means
Safari set_permission toggles a session permission and requires a bool value; any non-bool raises WebDriverException.
Source
Thrown at py/selenium/webdriver/safari/webdriver.py:79
def quit(self):
"""Closes the browser and shuts down the SafariDriver executable."""
try:
super().quit()
except Exception:
# We don't care about the message because something probably has gone wrong
pass
finally:
if not self.service.reuse_service:
self.service.stop()
# safaridriver extension commands. The canonical command support matrix is here:
# https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
# First available in Safari 11.1 and Safari Technology Preview 41.
def set_permission(self, permission, value):
if not isinstance(value, bool):
raise WebDriverException("Value of a session permission must be set to True or False.")
payload = {permission: value}
self.execute("SET_PERMISSIONS", {"permissions": payload})
# First available in Safari 11.1 and Safari Technology Preview 41.
def get_permission(self, permission):
payload = self.execute("GET_PERMISSIONS")["value"]
permissions = payload["permissions"]
if not permissions:
return None
if permission not in permissions:
return None
value = permissions[permission]
if not isinstance(value, bool):
return None
View on GitHub (pinned to aa36b38e69)
Solutions
- Pass True/False explicitly.
- Coerce carefully - note bool('false') is True, so parse strings explicitly.
Example fix
# before
driver.set_permission("clipboard", "true")
# after
driver.set_permission("clipboard", True) Defensive patterns
Strategy: validation
Validate before calling
def permission_value(v) -> bool:
if isinstance(v, bool):
return v
if isinstance(v, str) and v.lower() in ("true", "false"):
return v.lower() == "true"
raise WebDriverException("permission value must be bool") Prevention
- Use native bool for permission toggles.
- Parse string config values into bool before calling set_permission.
When it happens
Trigger: driver.set_permission('safari:permission', 1), set_permission(..., 'yes'), or set_permission(..., None).
Common situations: Reading a permission preference from config/env as a string or int.
Related errors
- Invalid permission state. Must be one of: ${Object.values(Pe
- Safari does not support options that are not namespaced
- Unexpected compiled output format. Expected it to start with
- Unexpected compiled output format. Expected it to start with
- Unexpected compiled output format. Expected it to start with
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/9e0f83fb72c95890.
Report an issue: GitHub.