Skip to content

Commit 82af771

Browse files
committed
check user_context_id for default and raise exception
1 parent 039ad35 commit 82af771

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

py/selenium/webdriver/common/bidi/browser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ def remove_user_context(self, user_context_id: str) -> None:
176176
------
177177
Exception: If the user context ID is "default" or does not exist.
178178
"""
179+
if user_context_id == "default":
180+
raise Exception("Cannot remove the default user context")
181+
179182
params = {"userContext": user_context_id}
180183
self.conn.execute(command_builder("browser.removeUserContext", params))
181184

py/test/selenium/webdriver/common/bidi/browser_tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ def test_get_client_windows(driver):
9191
assert window_info.get_y() >= 0
9292

9393

94+
@pytest.mark.xfail_safari
95+
def test_raises_exception_when_removing_default_user_context(driver):
96+
with pytest.raises(Exception):
97+
driver.browser.remove_user_context("default")
98+
99+
94100
@pytest.mark.xfail_safari
95101
def test_client_window_state_constants(driver):
96102
assert ClientWindowState.FULLSCREEN == "fullscreen"

0 commit comments

Comments
 (0)