NEW230612
[WebDriver] Fix element references after tab switch or close
https://bugs.webkit.org/show_bug.cgi?id=230612
Summary [WebDriver] Fix element references after tab switch or close
Carlos Garcia Campos
Reported 2021-09-22 05:31:31 PDT
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
Attachments
Radar WebKit Bug Importer
Comment 1 2021-09-29 05:32:16 PDT
Lauro Moura
Comment 2 2025-06-10 13:10:24 PDT
*** Bug 279099 has been marked as a duplicate of this bug. ***
Lauro Moura
Comment 3 2025-06-10 13:11:30 PDT
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 "no such element" error instead of "stale element reference".) > 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 "no such element" 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 > To get a known element given session and reference: > If not node reference is known with session, session's current browsing context, and reference return error with error code no such element. > <snip> https://w3c.github.io/webdriver/#dfn-node-reference-is-known > A node reference is known given session, browsing context, and reference if the following steps return true: > Let navigable be browsing context's active document's node navigable. > Let navigable seen nodes map be session's navigable seen nodes map. > If navigable seen nodes map contains navigable and navigable seen nodes map[navigable] contains reference, return true, otherwise return false.
Note You need to log in before you can comment on or make changes to this bug.