<?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>230612</bug_id>
          
          <creation_ts>2021-09-22 05:31:31 -0700</creation_ts>
          <short_desc>[WebDriver] Fix element references after tab switch or close</short_desc>
          <delta_ts>2026-04-01 18:51:44 -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>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=230551</see_also>
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Carlos Garcia Campos">cgarcia</reporter>
          <assigned_to name="Lauro Moura">lmoura</assigned_to>
          <cc>bburg</cc>
    
    <cc>lmoura</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1796021</commentid>
    <comment_count>0</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2021-09-22 05:31:31 -0700</bug_when>
    <thetext>We return stale element reference instead of no such element.

imported/w3c/webdriver/tests/element_clear/clear.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/element_click/click.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/element_send_keys/send_keys.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/get_element_attribute/get.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/get_element_css_value/get.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/get_element_property/get.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/get_element_rect/get.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/get_element_text/get.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/get_element_tag_name/get.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/is_element_enabled/enabled.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/is_element_selected/selected.py::test_no_top_browsing_context
imported/w3c/webdriver/tests/switch_to_window/switch.py::test_element_not_found_after_tab_switch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1798268</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-09-29 05:32:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/83667452&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2122813</commentid>
    <comment_count>2</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-06-10 13:10:24 -0700</bug_when>
    <thetext>*** Bug 279099 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2122814</commentid>
    <comment_count>3</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2025-06-10 13:11:30 -0700</bug_when>
    <thetext>Also imported/w3c/webdriver/tests/classic/switch_to_frame/switch.py::test_frame_id_null seems related to this.

Related changed in WPT by https://phabricator.services.mozilla.com/D101065 (Bug 1684827 - [wdspec] Fix switch to frame tests for &quot;no such element&quot; error instead of &quot;stale element reference&quot;.)

&gt; Element references are per browsing context. As such elements as found within a frame are not existent in any parent browsing context, and when retrieving these a &quot;no such element&quot; error has to be returned.

And relevant items in the spec, showing that references are checked against the current browsing context:

https://w3c.github.io/webdriver/#dfn-get-a-known-element

&gt; To get a known element given session and reference:
&gt;    If not node reference is known with session, session&apos;s current browsing context, and reference return error with error code no such element.
&gt;   &lt;snip&gt;

https://w3c.github.io/webdriver/#dfn-node-reference-is-known

&gt; A node reference is known given session, browsing context, and reference if the following steps return true:
&gt;    Let navigable be browsing context&apos;s active document&apos;s node navigable.
&gt;    Let navigable seen nodes map be session&apos;s navigable seen nodes map.
&gt;    If navigable seen nodes map contains navigable and navigable seen nodes map[navigable] contains reference, return true, otherwise return false.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196106</commentid>
    <comment_count>4</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2026-04-01 18:51:44 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/61870</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>