Closed alpatron closed 6 months ago
To add quick context (and get notifications on this issue)...
We discussed adding Scrolling to Actions endpoint at TPAC in Lyon because elements are not implicitly scrolled into view unlike with click endpoint. Not being able to scroll to an element that is outside of the viewport makes the scrolling feature mostly useless. We don't auto scroll in actions class because we need users to make intention clear, but that's what this does.
So, Chrome has the desired behavior, but does it match what is in the spec? Does the spec need to be changed to say if the origin is an element that is outside of the viewport it needs to be first scrolled into view?
Edit: For anyone who stumbles upon this issue from googling the exception, this appears to solve it in a cross-browser manner:
driver.execute_script("arguments[0].scrollIntoView();", element)
ActionChains(driver)...
Consider this solved, so sorry again for the ping :)
We don't auto scroll in actions class because we need users to make intention clear, but that's what this does.
Sorry to ping you ~8 months later, but any chance this had any traction, or do you have any recommendations for some fix?
We are working on porting some tests to the Actions API as it makes many things easier in CI, but it breaks a few of them in Firefox, and I would rather not pepper them all with things like
if self.selenium.name == "firefox" and self.selenium.capabilities.get("moz:headless") is False:
# hacks
else:
# normal stuff
Thanks in advance :)
So I had a look at the WebDriver classic spec and when reading steps 5 and 6 of the section dispatch a scroll action
it's clear that our implementation handles it correctly. The scroll action of a wheel input device should actually raise a move target out of bounds
error. If that is correct it's debatable. IMO it would be nice to allow scrolling to a given element whether if it's inside or outside the current viewport. @jgraham what do you think?
Here the Python implementation which doesn't take those checks into account: https://github.com/SeleniumHQ/selenium/blob/c1831460444ef70a6550a2983463e2618493f8c2/py/selenium/webdriver/common/action_chains.py#L323-L332
What is the point of scrolling, then?
The *whole point is to let you scroll to something out of screen in the Actions class, so you don't have to insert a "element once scrolled into view" equivalent command.
If this is spec compliant, we need to change the spec.
After speaking to @jgraham it turns out that the scroll
action of the wheel
input source is actually never meant to be used to "scroll to an element". Instead it has to be used to "scroll at the location of the element". That means that at least the code in the Python bindings is broken and needs to be fixed.
In regards of Webdriver it would need an action primitive to allow something like that.
Also see https://github.com/w3c/webdriver/issues/1635 for probably the same underlying issue.
Hello. I was trying to use the
scroll_to_element
method provided by the Actions API in the Python version of Selenium. The documentation says that this method should scroll elements into view, but if I try to use this method for this purpose I getMoveTargetOutOfBoundsException
. Given this behaviour, at least in my limited testing, appears only in Geckodriver, I filled this issue here.System
Testcase
HTML:
Selenium:
Stacktrace
Trace-level log
geckodriver.log