0

I'm using this method, for scroll down till the element is visible:

var element = driver.FindElement(By.id("element-id"));
Actions actions = new Actions(driver);
actions.MoveToElement(element);
actions.Perform();

It stopped working, with last version of Chrome 65.0.3325.146, Chrome driver 2.36 and Selenium 3.10

Do you have any information, what happened with this method?

Do you have any suggestions, how to scroll till element is visible?

It is not a duplicate. Unable to scroll down to bottom of div with data loading dynamically not resolved my problem.

8
  • What does exactly happen? Does it return any error or exception?
    – Shahid
    Mar 12, 2018 at 4:58
  • I can not scroll to an element at the bottom of the page. No error, no exeption.
    – Majkl
    Mar 12, 2018 at 7:27
  • 1
  • Not a duplicate. Looks like Se3 broke the actions.MoveToElement behavior, as @SahilMutreja noted in his answer. Mar 12, 2018 at 14:23
  • It is not a duplicate. Unable to scroll down to bottom of div with data loading dynamically not resolved my problem.
    – Majkl
    Mar 12, 2018 at 14:38

2 Answers 2

2

Selenium 3 has no support yet for Actions class driver. Please Check

You can try out my following code snippet. It does exactly what you need.

 //@param element is the WebElement that you want to scroll to and then click
    public void scrollIntoViewClick(WebElement element) { 
        js.executeScript("arguments[0].scrollIntoView(true);", element);
        js.executeScript("arguments[0].click();", element);
    }

Above function uses selenium to execute vanilla JS and then scroll till the element that you want to click, once its visible on the screen then perform a click on it.

Hope this answers your question :)

2
  • 2
    +1 with addition: js.executeScript should be used ONLY to scroll the element into view, as temporary replacement of Action.move, preferably in it's own helper method. Eventually, they will fix Se3 and then you can revert to doing it "the right way", so best is to have the hack in fewer places. Good tip and good to know. Mar 12, 2018 at 14:19
  • The problem will not be solved by this code. Other suggestions, please.
    – Majkl
    Mar 12, 2018 at 14:37
0

The same problem happen to me. This happens when your browser (in this case chrome) updates the minor version. The selenium can still load the drivers and an instance of it can be instantiated, because it (probably) checks the major version.

I was using the scroll action with JS, so after the update it didn't work, but only this didn't work in running mode, scrolling using JS. Though it still worked fine in debug. Maybe it's something related to JS, in running mode that cause this problem.

Solution : update your webdriver and check the minor version to match.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.