3

How can we scroll a specific DIV inside a webpage using Selenium WebDriver ? NOT scrolling the complete webpage, BUT scrolling a specific DIV inside the webpage.

for exp:- https://groups.google.com/forum/#!forum/ibm.software.websphere.application-server

  • need to "scroll the contents down"

tried:-

Actions act2 = new Actions(browser);
WebElement draggablePartOfScrollbar=browser.findElement(By.className("G3J0AAD-b-F"));
act2.moveToElement(draggablePartOfScrollbar).clickAndHold().moveByOffset(0, 250).release().build().perform();

This is working but this is not scrolling and it fails sometime by mistakenly clicking some content.

1 Answer 1

4

I'm posting my solution which I used for above problem:

  1. First click on the scroll-able pane of your page:

    Actions clickAction = new Actions(groupBrowser);
    WebElement scrollablePane = groupBrowser.findElement(By
            .className("G3J0AAD-b-F"));
    clickAction.moveToElement(scrollablePane).click().build().perform();
    
  2. Then scroll with below code:

    Actions scrollAction = new Actions(groupBrowser);
    scrollAction.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
    Thread.currentThread().sleep(5000);
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.