<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>296255</bug_id>
          
          <creation_ts>2025-07-20 16:31:46 -0700</creation_ts>
          <short_desc>[WebDriver] Selenium 4.34 tests teardown error due to reconnection errors on test failure</short_desc>
          <delta_ts>2025-09-25 21:50:12 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebDriver</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>295405</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Lauro Moura">lmoura</reporter>
          <assigned_to name="Lauro Moura">lmoura</assigned_to>
          <cc>bburg</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2131504</commentid>
    <comment_count>0</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-07-20 16:31:46 -0700</bug_when>
    <thetext>In the bug295405 Selenium test update, the new bidi.storage tests are failing with what looks like reconnection errors:

ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_get_cookie_by_name[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=40445):
 Max retries exceeded with url: /session/d6f7141a-b5a5-4e8c-813d-37470d6a0b77 (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a0e9d7c0&gt;: Failed to establish a new connection: [Errno 111] Conn...     
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_get_cookie_in_default_user_context[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhos
t&apos;, port=38865): Max retries exceeded with url: /session/14f040b5-45b1-4ac8-a5f9-c0a926afda49 (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a064a810&gt;: Failed to establish a new connection: [Errno 1
11] Conn...                                                                                                                                                                                                                              
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_get_cookie_in_a_user_context[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, po
rt=56063): Max retries exceeded with url: /session/c42c3811-de0e-45f7-b51b-1f511b314dc0 (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a0eed130&gt;: Failed to establish a new connection: [Errno 111] Conn...                                                                                                                                                                                                                                    
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_add_cookie[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=55731): Max ret
ries exceeded with url: /session/263ae190-9cde-499a-beec-d1b13d39d955 (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a0f24560&gt;: Failed to establish a new connection: [Errno 111] Conn...             
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_add_and_get_cookie[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=46527):
 Max retries exceeded with url: /session/269b3359-70d1-4258-b4d8-3da62db327f2 (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a0efc470&gt;: Failed to establish a new connection: [Errno 111] Conn...     ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_get_all_cookies[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=33295): Ma
x retries exceeded with url: /session/5f2d5ddb-c583-4408-8c32-dd8e6c18757f (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a0efcf80&gt;: Failed to establish a new connection: [Errno 111] Conn...        
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_delete_all_cookies[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=55909):
 Max retries exceeded with url: /session/e2de1f65-181f-465e-b607-4f7044bbaf5b (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a0efdb50&gt;: Failed to establish a new connection: [Errno 111] Conn...     
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_delete_cookie_with_name[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=58
891): Max retries exceeded with url: /session/10d95670-c128-463e-9adb-32dbb08339e9 (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a02598e0&gt;: Failed to establish a new connection: [Errno 111] Conn...
ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_storage_tests.py::TestBidiStorage::test_add_cookies_with_different_paths[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=51283): Max retries exceeded with url: /session/4c0afa55-349a-4164-b1c4-0a2fe483f36b (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x7085a01a2450&gt;: Failed to establish a new connection: [Errno 111
] Conn...     

Not sure if the way the storage tests are run, inside a class, is messing up some fixture order or something like that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2131505</commentid>
    <comment_count>1</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-07-20 16:44:21 -0700</bug_when>
    <thetext>Just confirmed that this is not a storage-specific thing. In the `imported/selenium/py/test/selenium/webdriver/common/bidi_browsing_context_tests.py::test_activate_browsing_context[wpewebkit]` test we get the same issue:

ERROR WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_browsing_context_tests.py::test_activate_browsing_context[wpewebkit] - urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=&apos;localhost&apos;, port=43417): Max retries exceeded with url: /session/2dbd1aad-adca-4c11-9428-63076266640a (Caused by NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection o...
FAILED WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_browsing_context_tests.py::test_activate_browsing_context[wpewebkit] - assert False

And verbose log from the failed assertion until the teardown:

selenium.webdriver.remote.remote_connection: [DEBUG] POST http://localhost:43417/session/2dbd1aad-adca-4c11-9428-63076266640a/execute/sync {&apos;script&apos;: &apos;return document.hasFocus();&apos;, &apos;args&apos;: []}                                         
urllib3.connectionpool: [DEBUG] http://localhost:43417 &quot;POST /session/2dbd1aad-adca-4c11-9428-63076266640a/execute/sync HTTP/1.1&quot; 200 15                                                                                                 
selenium.webdriver.remote.remote_connection: [DEBUG] Remote response: status=200 | data={&quot;value&quot;:false} | headers=HTTPHeaderDict({&apos;Server&apos;: &apos;WebKitWebDriver&apos;, &apos;Date&apos;: &apos;Sun, 20 Jul 2025 23:41:51 GMT&apos;, &apos;Content-Type&apos;: &apos;application/json
; charset=utf-8&apos;, &apos;Cache-Control&apos;: &apos;no-cache&apos;, &apos;Content-Length&apos;: &apos;15&apos;})                                                                                                                                                                  selenium.webdriver.remote.remote_connection: [DEBUG] Finished Request                                                                                                                                                                    
FAILEDselenium.webdriver.remote.remote_connection: [DEBUG] DELETE http://localhost:43417/session/2dbd1aad-adca-4c11-9428-63076266640a {}                                                                                                 
urllib3.connectionpool: [DEBUG] http://localhost:43417 &quot;DELETE /session/2dbd1aad-adca-4c11-9428-63076266640a HTTP/1.1&quot; 200 14                                                                                                            
selenium.webdriver.remote.remote_connection: [DEBUG] Remote response: status=200 | data={&quot;value&quot;:null} | headers=HTTPHeaderDict({&apos;Server&apos;: &apos;WebKitWebDriver&apos;, &apos;Date&apos;: &apos;Sun, 20 Jul 2025 23:41:51 GMT&apos;, &apos;Content-Type&apos;: &apos;application/json;
 charset=utf-8&apos;, &apos;Cache-Control&apos;: &apos;no-cache&apos;, &apos;Content-Length&apos;: &apos;14&apos;})                                                                                                                                                                   selenium.webdriver.remote.remote_connection: [DEBUG] Finished Request                                                                                                                                                                    
selenium.webdriver.remote.remote_connection: [DEBUG] DELETE http://localhost:43417/session/2dbd1aad-adca-4c11-9428-63076266640a {}                                                                                                       
urllib3.connectionpool: [DEBUG] Starting new HTTP connection (1): localhost:43417                                                                                                                                                        
urllib3.util.retry: [DEBUG] Incremented Retry for (url=&apos;/session/2dbd1aad-adca-4c11-9428-63076266640a&apos;): Retry(total=2, connect=None, read=None, redirect=None, status=None)                                                             
urllib3.connectionpool: [WARNING] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by &apos;NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x718406060c50&gt;: Failed to 
establish a new connection: [Errno 111] Connection refused&apos;)&apos;: /session/2dbd1aad-adca-4c11-9428-63076266640a                                                                                                                             urllib3.connectionpool: [DEBUG] Starting new HTTP connection (2): localhost:43417                                                                                                                                                        
urllib3.util.retry: [DEBUG] Incremented Retry for (url=&apos;/session/2dbd1aad-adca-4c11-9428-63076266640a&apos;): Retry(total=1, connect=None, read=None, redirect=None, status=None)                                                             
urllib3.connectionpool: [WARNING] Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by &apos;NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x718406061160&gt;: Failed to 
establish a new connection: [Errno 111] Connection refused&apos;)&apos;: /session/2dbd1aad-adca-4c11-9428-63076266640a                                                                                                                             
urllib3.connectionpool: [DEBUG] Starting new HTTP connection (3): localhost:43417                                                                                                                                                        
urllib3.util.retry: [DEBUG] Incremented Retry for (url=&apos;/session/2dbd1aad-adca-4c11-9428-63076266640a&apos;): Retry(total=0, connect=None, read=None, redirect=None, status=None)                                                             
urllib3.connectionpool: [WARNING] Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by &apos;NewConnectionError(&apos;&lt;urllib3.connection.HTTPConnection object at 0x718406061790&gt;: Failed to 
establish a new connection: [Errno 111] Connection refused&apos;)&apos;: /session/2dbd1aad-adca-4c11-9428-63076266640a                                                                                                                             
urllib3.connectionpool: [DEBUG] Starting new HTTP connection (4): localhost:43417                                                                                                                                                        
                                                                                                                                                                                                                                         
[2025-07-20 20:41:49] WebDriverTests/imported/selenium/py/test/selenium/webdriver/common/bidi_browsing_context_tests.py::test_activate_browsing_context[wpewebkit] ERROR</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2132764</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-07-27 16:32:12 -0700</bug_when>
    <thetext>&lt;rdar://problem/156868087&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2138885</commentid>
    <comment_count>3</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-08-26 13:41:05 -0700</bug_when>
    <thetext>A bit more detail:

- This manifests when a test case on a given file fails. If all tests are passing, no problem.
- Interestingly, `xfail` reports the failure, but the teardown error doesn&apos;t seem to happen
- The same selenium test suite works fine when invoked from bazel or manual pytest (from Selenium repository)

(Also update the title as it&apos;s not BiDi-related)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2138971</commentid>
    <comment_count>4</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-08-26 20:38:16 -0700</bug_when>
    <thetext>So, the issue is related to selenium&apos;s pytest fixtures trying to send the quit command after the original driver had already exited.

I&apos;ll submit a patch upstream and likely do another import in this issue, as we already have selenium 4.35 out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2142870</commentid>
    <comment_count>5</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-09-14 20:11:38 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/50727</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2146065</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-09-25 21:50:09 -0700</bug_when>
    <thetext>Committed 300552@main (840ba04a5102): &lt;https://commits.webkit.org/300552@main&gt;

Reviewed commits have been landed. Closing PR #50727 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>