Selenium: actions.moveToElement in Selenium does not scroll down the page

Created on 9 Jun 2017  路  2Comments  路  Source: SeleniumHQ/selenium

Hi,

After upgrading our project to use latest Selenium Version(3.4.0), gecko driver(Version "geckodriver-v0.16.0-win64") and FF 53.0, found that a feature to scroll down the page is not working. Tried many different techniques but didn't find any way to scroll the page to go through required element. We are using below code to go through this:

public T scroll_to_element(By element) {
WebElement webElement = findElement(element);
Actions actions = new Actions(driver);
actions.moveToElement(webElement).perform();
return me();
}

Also, all the classes related to Actions.java is showing deprecated in the above said version of selenium(3.4.0). If those are deprecated, what is the next option we have ?

Please advise.

G-w3c

Most helpful comment

Workaround on Java:

WebElement element = driver.findElement(locator);
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

All 2 comments

Workaround on Java:

WebElement element = driver.findElement(locator);
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

Unfortunately, this feature could not find its way to the W3C WebDriver Specification Level 1 and it's not going to be implemented in geckodriver until Level 2.

Follow the spec issue: https://github.com/w3c/webdriver/issues/1005

Was this page helpful?
0 / 5 - 0 ratings