|
17 | 17 |
|
18 | 18 | import pytest |
19 | 19 |
|
| 20 | +from selenium.common.exceptions import WebDriverException |
20 | 21 | from selenium.webdriver.common.bidi.browsing_context import ReadinessState |
21 | 22 | from selenium.webdriver.common.bidi.network import Request |
22 | 23 | from selenium.webdriver.common.by import By |
@@ -101,17 +102,19 @@ def test_remove_auth_handler(driver): |
101 | 102 | @pytest.mark.xfail_firefox(reason="Data URLs in Network requests are not implemented in Firefox yet") |
102 | 103 | def test_handler_with_data_url_request(driver, pages): |
103 | 104 | data_requests = [] |
| 105 | + exceptions = [] |
104 | 106 |
|
105 | 107 | def callback(request: Request): |
106 | 108 | if request.url.startswith("data:"): |
107 | 109 | data_requests.append(request) |
108 | | - request.continue_request() |
| 110 | + try: |
| 111 | + request.continue_request() |
| 112 | + except WebDriverException as e: |
| 113 | + exceptions.append(e) |
109 | 114 |
|
110 | 115 | driver.network.add_request_handler("before_request", callback) |
111 | 116 | url = pages.url("data_url.html") |
112 | 117 | driver.browsing_context.navigate(context=driver.current_window_handle, url=url, wait=ReadinessState.COMPLETE) |
113 | | - |
114 | | - # Assert that the BiDi event was captured. |
115 | | - assert len(data_requests) > 0 |
116 | | - # Assert that the image is displayed. |
117 | 118 | assert driver.find_element(By.ID, "data-url-image").is_displayed() |
| 119 | + assert len(data_requests) > 0, "BiDi event not captured" |
| 120 | + assert len(exceptions) == 0, "Exception raised when continuing request in callback" |
0 commit comments