1818import base64
1919
2020import filetype
21+ import pytest
22+ from urllib3 .exceptions import ReadTimeoutError
23+
24+ from selenium import webdriver
25+ from selenium .webdriver .common .by import By
26+ from selenium .webdriver .remote .client_config import ClientConfig
2127
2228
2329def test_browser_specific_method (driver , pages ):
@@ -27,3 +33,20 @@ def test_browser_specific_method(driver, pages):
2733 result = base64 .b64decode (screenshot )
2834 kind = filetype .guess (result )
2935 assert kind is not None and kind .mime == "image/png"
36+
37+
38+ def test_remote_webdriver_with_http_timeout (firefox_options , webserver ):
39+ """This test starts a remote webdriver with an http client timeout
40+ set less than the implicit wait timeout, and verifies the http timeout
41+ is triggered first when waiting for an element.
42+ """
43+ http_timeout = 6
44+ wait_timeout = 8
45+ server_addr = f"http://{ webserver .host } :{ webserver .port } "
46+ client_config = ClientConfig (remote_server_addr = server_addr , timeout = http_timeout )
47+ assert client_config .timeout == http_timeout
48+ with webdriver .Remote (options = firefox_options , client_config = client_config ) as driver :
49+ driver .get (f"{ server_addr } /simpleTest.html" )
50+ driver .implicitly_wait (wait_timeout )
51+ with pytest .raises (ReadTimeoutError ):
52+ driver .find_element (By .ID , "no_element_to_be_found" )
0 commit comments