Bug 232996 - rect returns wrong coordinates after calling scrollIntoView
Summary: rect returns wrong coordinates after calling scrollIntoView
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebDriver (show other bugs)
Version: Safari 14
Hardware: Mac (Intel) macOS 11
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-11 06:38 PST by sebastian.klaar
Modified: 2021-11-15 04:25 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sebastian.klaar 2021-11-11 06:38:21 PST
We're using webdriverio to execute automated tests on Safari.

The w3c command "scrollIntoView" causes the following command to return wrong coordinates:
/session/:sessionId/element/:elementId/rect": {
"GET": {
"command": "getElementRect",
"description": "The Get Element Rect command returns the dimensions and coordinates of the given web element.",
"ref": "https://w3c.github.io/webdriver/#dfn-get-element-rect",
"variables": [{
"name": "elementId",
"description": "the id of an element returned in a previous call to Find Element(s)"
}],
"parameters": [],
"returns": {
"type": "Object",
"name": "elementRect",
"description": "A JSON object representing the position and bounding rect of the element."
}
}
}, 

The returned values are off by the amount of scroll range. According to the w3c specification "rect" should return coordinates relative to the browsing context and not to the viewport.
Comment 1 sebastian.klaar 2021-11-11 06:38:43 PST
reference: https://feedbackassistant.apple.com/feedback/9381783
Comment 2 Sam Sneddon [:gsnedders] 2021-11-15 04:25:40 PST
rdar://80958449

> According to the w3c specification "rect" should return coordinates relative to the browsing context

No, it's "relative to the current browsing context’s document element"

WPT has some failing tests, though not scrolling first: https://wpt.fyi/results/webdriver/tests/get_element_rect/get.py?label=experimental&label=master&aligned