NEW 275375
[WebDriver] keyup events are not delivered when any modifier key is involved
https://bugs.webkit.org/show_bug.cgi?id=275375
Summary [WebDriver] keyup events are not delivered when any modifier key is involved
Qianlang Chen
Reported 2024-06-11 15:24:14 PDT
Suppose we start with this Python 3 code (with Selenium 4 installed): import time from selenium.webdriver import Safari, Keys driver = Safari() driver.get(".../some/webpage.html") time.sleep(2) If we do driver.find_element("tag name", "body").send_keys("abc") # Case 1 Then, for each of the keys A, B, and C, a `keydown` even is sent and a `keyup` event immediately follows. This is correct and is what happens even if the browser window loses input focus. However, if we do driver.find_element("tag name", "body").send_keys(Keys.COMMAND, "a") Then, - If the browser window is focused, a `keydown` for Command is sent and a `keydown` event for A are sent. No `keyup` events are sent at all. (Case 2) - If the browser window is NOT focused, a `keydown` for Command is sent, and that's it. (Case 3) If we log in the target webpage details of the events it receives, this is what we see: - Case 1: {"type":"keydown","key":"a","metaKey":false} {"type":"keyup","key":"a","metaKey":false} {"type":"keydown","key":"b","metaKey":false} {"type":"keyup","key":"b","metaKey":false} {"type":"keydown","key":"c","metaKey":false} {"type":"keyup","key":"c","metaKey":false} - Case 2: {"type":"keydown","key":"Meta","metaKey":true} {"type":"keydown","key":"a","metaKey":true} - Case 3: {"type":"keydown","key":"Meta","metaKey":true} Case 1 is correct. The correct log for both Case 2 and Case 3 should be: {"type":"keydown","key":"Meta","metaKey":true} {"type":"keydown","key":"a","metaKey":true} {"type":"keyup","key":"a","metaKey":true} {"type":"keyup","key":"Meta","metaKey":false} And this is the output of Chrome/chromedriver, regardless of whether the window is focused.
Attachments
The webpage in a sample test case: host this on `http://localhost:8000` (752 bytes, text/html)
2024-06-11 15:25 PDT, Qianlang Chen
no flags
The Python test driver (348 bytes, text/x-python-script)
2024-06-11 15:26 PDT, Qianlang Chen
no flags
Qianlang Chen
Comment 1 2024-06-11 15:25:22 PDT
Created attachment 471653 [details] The webpage in a sample test case: host this on `http://localhost:8000`
Qianlang Chen
Comment 2 2024-06-11 15:26:03 PDT
Created attachment 471654 [details] The Python test driver
Radar WebKit Bug Importer
Comment 3 2024-06-11 15:26:19 PDT
Note You need to log in before you can comment on or make changes to this bug.