[Webkit-unassigned] [Bug 275326] New: [WebDriver] If Safari window is not focused, WebDriver-automated mouse events do not get sent to the page
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Jun 10 12:42:04 PDT 2024
https://bugs.webkit.org/show_bug.cgi?id=275326
Bug ID: 275326
Summary: [WebDriver] If Safari window is not focused,
WebDriver-automated mouse events do not get sent to
the page
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: WebDriver
Assignee: webkit-unassigned at lists.webkit.org
Reporter: qianlangchen at apple.com
CC: bburg at apple.com
When using WebDriver/safaridriver to automate mouse events, if the target Safari window isn't focused, these mouse events may not work at all.
To reproduce,
1. host this webpage named `a.html` on `localhost:8000`:
<!DOCTYPE html>
<html>
<head></head>
<body>
Hello
<script>
const handle = (e) => {
let info = JSON.stringify({
type: e.type,
pageX: e.pageX,
pageY: e.pageY,
target: e.target,
});
let el = document.createElement("div");
el.textContent = info;
document.body.append(el);
};
window.addEventListener("mousemove", handle);
window.addEventListener("mousedown", handle);
window.addEventListener("mouseup", handle);
</script>
</body>
</html>
2. Run the following Python 3 code with Selenium 4 installed:
import time
from selenium.webdriver import Safari
driver = Safari()
driver.get("http://localhost:8000/a.html")
time.sleep(5)
driver.find_element("tag name", "body").click()
time.sleep(42)
3. Observe that, if the Safari window is focused when the `click()` automation code runs (after about 5 seconds from the start), then three event logs show up in the webpage:
{"type":"mousemove","pageX":256,"pageY":13,"target":{}}
{"type":"mousedown","pageX":256,"pageY":20,"target":{}}
{"type":"mouseup","pageX":256,"pageY":20,"target":{}}
(Your events may have slightly different coordinates.)
However, if the window isn't focused, either because it didn't come to the top natively when the script created it or because you quickly focused a different window in 5 seconds, then no logs show up in the webpage at all, meaning the automated events failed to be delivered.
The expected behavior should be that the automated events get delivered to the Safari window and the webpage regardless of whether the window is focused, like in Firefox or Chrome.
rdar://117035696
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20240610/39e11c63/attachment.htm>
More information about the webkit-unassigned
mailing list