File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
py/test/selenium/webdriver/common Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 1616# under the License.
1717
1818import http .server
19- import socket
2019import socketserver
2120import threading
2221
2524from selenium .webdriver .common .bidi .browser import ClientWindowInfo , ClientWindowState
2625from selenium .webdriver .common .by import By
2726from selenium .webdriver .common .proxy import Proxy , ProxyType
27+ from selenium .webdriver .common .utils import free_port
2828from selenium .webdriver .common .window import WindowTypes
2929
3030
31- def get_free_port ():
32- with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
33- s .bind (("" , 0 ))
34- return s .getsockname ()[1 ]
35-
36-
3731class FakeProxyHandler (http .server .SimpleHTTPRequestHandler ):
3832 def do_GET (self ):
3933 print (f"[Fake Proxy] Intercepted request to: { self .path } " )
@@ -170,7 +164,7 @@ def test_create_user_context_with_direct_proxy(driver):
170164def test_create_user_context_with_manual_proxy_all_params (driver ):
171165 """Test creating a user context with manual proxy configuration."""
172166 # Start a fake proxy server
173- port = get_free_port ()
167+ port = free_port ()
174168 fake_proxy_server = start_fake_proxy (port = port )
175169
176170 proxy = Proxy ()
@@ -210,7 +204,7 @@ def test_create_user_context_with_manual_proxy_all_params(driver):
210204def test_create_user_context_with_both_params (driver ):
211205 """Test creating a user context with both acceptInsecureCerts and proxy parameters."""
212206 # Start fake proxy server
213- port = get_free_port ()
207+ port = free_port ()
214208 fake_proxy_server = start_fake_proxy (port = port )
215209
216210 proxy = Proxy ()
You can’t perform that action at this time.
0 commit comments