jonhoo / fantoccini

A high-level API for programmatically interacting with web pages through WebDriver.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question]: Is there a method to scroll?

saona-raimundo opened this issue · comments

Hi! Thank you for the crate! It has been quite useful for me.

I could not find a method called "scroll" and I checked the webdriver crate without luck, so I wanted to ask you directly;
Is there a way to control the website and scroll?

Use case

Clicking into an element implies first scrolling into the element into view, and then clicking (by W3 protocol). I wanted to check if an element can be scrolled into view before trying to click on it.

In my case, being able to scroll an element into view tells me that the website is in some state. Therefore, I can do some operations before clicking this element.

In short, I want to do something in between scrolling and clicking an element. Is there a way to do it?

You should be able to use Client::execute along with something like window.scroll in JavaScript to do this :)

Thank you!

I forgot about executing JavaScript :D

For my use case, I will be using element.scrollIntoView.