简体   繁体   中英

Java Selenium WebDriver - How to set ScrollBehavior (elementScrollBehavior) without using Remote WebDriver?

on my website I'm trying to automate, there is a floating header. As selenium is always scrolling to the top of an element, I'm getting the error message that some other element would receive the click. After searching a bit on the net, there should be a solution to set the scroll behavior (elementScrollBehavior) as a desired capability.

Now my question: As Desired Capabilities is for remote WebDriver implementation, it's not really useful in my case. Is there a possibility to change the scroll behavior in a way, that I can run my local instance with the behavior of scolling to buttom of an element?

Many Thanks & Regards!

Desired capabilities are not only for RemoteWebDriver implementation, you can set it even on your local driver instances. For example, if you are using FirefoxDriver you could do something like this in your case:

DesiredCapabilities cap = new DesiredCapabilities();
driver = new FirefoxDriver(cap.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, 1);

You can also use RemoteWebDriver on your local machine (just pass localhost url), your localhost can also be selenium node, it doesn't have to be on some remote machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM