Skip to content

Commit c1ee86d

Browse files
committed
add test
1 parent f122bd3 commit c1ee86d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

py/test/selenium/webdriver/common/bidi_browser_tests.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import pytest
2323

2424
from selenium.webdriver.common.bidi.browser import ClientWindowInfo, ClientWindowState
25+
from selenium.webdriver.common.bidi.session import UserPromptHandler, UserPromptHandlerType
2526
from selenium.webdriver.common.by import By
2627
from selenium.webdriver.common.proxy import Proxy, ProxyType
2728
from selenium.webdriver.common.utils import free_port
@@ -235,3 +236,29 @@ def test_create_user_context_with_proxy_and_accept_insecure_certs(driver):
235236
driver.browser.remove_user_context(user_context)
236237
fake_proxy_server.shutdown()
237238
fake_proxy_server.server_close()
239+
240+
241+
def test_create_user_context_with_unhandled_prompt_behavior(driver, pages):
242+
"""Test creating a user context with unhandled prompt behavior configuration."""
243+
prompt_handler = UserPromptHandler(
244+
alert=UserPromptHandlerType.DISMISS, default=UserPromptHandlerType.DISMISS, prompt=UserPromptHandlerType.DISMISS
245+
)
246+
247+
user_context = driver.browser.create_user_context(unhandled_prompt_behavior=prompt_handler)
248+
assert user_context is not None
249+
250+
# create a new browsing context with the user context
251+
bc = driver.browsing_context.create(type=WindowTypes.WINDOW, user_context=user_context)
252+
assert bc is not None
253+
254+
driver.switch_to.window(bc)
255+
pages.load("alerts.html")
256+
257+
# TODO: trigger an alert and test that it is dismissed automatically, currently not working,
258+
# conftest.py unhandled_prompt_behavior set to IGNORE, see if it is related
259+
# driver.find_element(By.ID, "alert").click()
260+
# # accessing title should be possible since alert is auto handled
261+
# assert driver.title == "Testing Alerts"
262+
263+
# Clean up
264+
driver.browser.remove_user_context(user_context)

0 commit comments

Comments
 (0)