Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "scroll into view" Actions primitive #1005

Open
shs96c opened this issue Aug 11, 2017 · 8 comments
Open

Missing "scroll into view" Actions primitive #1005

shs96c opened this issue Aug 11, 2017 · 8 comments
Milestone

Comments

@shs96c
Copy link
Contributor

shs96c commented Aug 11, 2017

Mid-way through executing a sequence of actions it's useful to be able to scroll an element into view. A "scroll into view" primitive would enable this.

@andreastt
Copy link
Member

Is this meant to target level 2? It seems more like an omission from the actions API than scope creep to me.

@shs96c
Copy link
Contributor Author

shs96c commented Aug 15, 2017

Yeah, it's level 2. @jgraham and I discussed this on the IRC channel a few months ago. Adding it requires us to add new functionality, and that's something we're not meant to do in the CR period.

@gsnedders
Copy link
Contributor

IMO, we should follow what CSSOM View does here and offer all three of scrollIntoView, scrollTo, and scrollBy on elements.

@shs96c
Copy link
Contributor Author

shs96c commented May 24, 2018 via email

@gsnedders
Copy link
Contributor

Element.prototype.scroll is identical to Element.prototype.scrollTo; both Element.prototype.scrollBy and Element.prototype.scrollTo call an internal function that does the actual scrolling.

@andreastt
Copy link
Member

I spoke to some users earlier today and they wanted the ability to scroll both by an amount and by web element, e.g. scroll(web element reference). AIUI scrollTo and scrollBy both take coordinates.

Some observations:

  • scrollTo takes ScrollIntoViewOptions: I’m assuming we’d use the same options we do for Element Send Keys and Element Click.
  • scrollBy takes either an options dictionary (top/left), or X/Y coordinates.

This all sounds straight forward, but I have two open questions:

  1. Are we fine with pixels make out the unit of scrolling? What if the user wants to scroll one height of the viewport (100vh)?
  2. The user would have to build up a mental model of where the viewport is at the moment, and writing interoperable tests across different device configurations would be hard.

@whimboo
Copy link
Contributor

whimboo commented Nov 7, 2018

Here the resolution from TPAC (minutes):

Add general "scroll" action primitive that takes the same input as pointerMove, except for origin it will not take the "pointer" variant, but it will have one called "relative" that is relative to the viewport. x/y offset will be given in pixels, and it will take the same ScrollIntoViewOptions defaults as the high level Element Click command.

@christian-bromann
Copy link
Member

christian-bromann commented Jan 4, 2024

fwiw: WebdriverIO has a custom implementation for this behavior that we have battle tested: https://github.com/webdriverio/webdriverio/blob/main/packages/webdriverio/src/commands/element/scrollIntoView.ts. It will fall back to the Web API if the remote environment doesn't support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants