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.

  • What does exactly happen? Does it return any error or exception? – Shahid Mar 12 '18 at 4:58
  • I can not scroll to an element at the bottom of the page. No error, no exeption. – Majkl Mar 12 '18 at 7:27
  • 1
  • Not a duplicate. Looks like Se3 broke the actions.MoveToElement behavior, as @SahilMutreja noted in his answer. – Peter M. - stands for Monica Mar 12 '18 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 '18 at 14:38
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
    +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. – Peter M. - stands for Monica Mar 12 '18 at 14:19
  • The problem will not be solved by this code. Other suggestions, please. – Majkl Mar 12 '18 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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