Skip to content

Commit e1af59e

Browse files
committed
Removed unused Response functionality - refined tests. All that fails is continue_request and continue_with_auth
1 parent a5da929 commit e1af59e

File tree

2 files changed

+8
-57
lines changed

2 files changed

+8
-57
lines changed

py/selenium/webdriver/common/bidi/network.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -300,38 +300,4 @@ def continue_request(self, **kwargs):
300300
if self.url is not None:
301301
params["url"] = self.url
302302

303-
self.network.conn.execute(self.command_builder("network.continueWithRequest", params))
304-
305-
306-
class Response:
307-
"""Represents an intercepted network response."""
308-
309-
def __init__(self, request_id, url, status_code, headers, body, network: Network):
310-
self.request_id = request_id
311-
self.url = url
312-
self.status_code = status_code
313-
self.headers = headers
314-
self.body = body
315-
self.conn = network
316-
317-
def command_builder(self, method, params):
318-
"""Build a command iterator to send to the network.
319-
320-
Parameters:
321-
----------
322-
method (str): The method to execute.
323-
params (dict): The parameters to pass to the method.
324-
"""
325-
command = {"method": method, "params": params}
326-
cmd = yield command
327-
return cmd
328-
329-
# def continue_response(self):
330-
# """Continue after receiving a response."""
331-
# params = {"requestId": self.request_id, "status": self.status_code}
332-
# if self.headers is not None:
333-
# params["headers"] = self.headers
334-
# if self.body is not None:
335-
# params["body"] = self.body
336-
# command = {"method": "network.continueResponse", "params": params}
337-
# self.network.conn.execute(self._command_iterator(command))
303+
self.network.conn.execute(self.command_builder("network.continueWithRequest", params))

py/test/selenium/webdriver/common/bidi_network_tests.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,8 @@ def test_remove_intercept(driver):
3838
driver.network.remove_intercept(result["intercept"])
3939
assert driver.network.intercepts == [], "Intercept not removed"
4040

41-
4241
@pytest.mark.xfail_safari
43-
def test_add_request_handler(driver, pages):
44-
45-
requests = []
46-
47-
def callback(request):
48-
requests.append(request)
49-
50-
callback_id = driver.network.add_request_handler("before_request", callback)
51-
assert callback_id is not None, "Request handler not added"
52-
driver.get("http://www.google.com")
53-
assert requests, "No requests intercepted"
54-
55-
56-
@pytest.mark.xfail_safari
57-
def test_remove_request_handler(driver, pages):
42+
def test_add_and_remove_request_handler(driver, pages):
5843

5944
requests = []
6045

@@ -64,9 +49,9 @@ def callback(request):
6449
callback_id = driver.network.add_request_handler("before_request", callback)
6550
assert callback_id is not None, "Request handler not added"
6651
driver.network.remove_request_handler("before_request", callback_id)
67-
driver.get("http://www.google.com")
68-
assert not requests, "No requests intercepted"
69-
52+
pages.load("formPage.html")
53+
assert not requests, "Requests intercepted"
54+
assert driver.find_element(By.NAME, "login").is_displayed(), "Request not continued"
7055

7156
@pytest.mark.xfail_safari
7257
def test_continue_request(driver, pages):
@@ -76,8 +61,8 @@ def callback(request: Request):
7661

7762
callback_id = driver.network.add_request_handler("before_request", callback)
7863
assert callback_id is not None, "Request handler not added"
79-
driver.get("http://www.google.com")
80-
assert driver.title == "Site is not secure", "Request not continued"
64+
pages.load("formPage.html")
65+
assert driver.find_element(By.NAME, "login").is_displayed(), "Request not continued"
8166

8267

8368
@pytest.mark.xfail_safari
@@ -86,4 +71,4 @@ def test_continue_with_auth(driver, pages):
8671
callback_id = driver.network.add_auth_handler("test", "test")
8772
assert callback_id is not None, "Request handler not added"
8873
pages.load("basicAuth")
89-
assert driver.find_element(By.TAG_NAME, "h1").text == "authorized", "Authorization failed"
74+
assert driver.find_element(By.TAG_NAME, "h1").text == "authorized", "Authorization failed"

0 commit comments

Comments
 (0)