Prabhu R
Prabhu R

Reputation: 14222

Selenium Webdriver, scrolling inside a div popup

There is a pop that is displayed which has a content that large that will have to scroll to view it completely. Is there was to scroll the content within the div that is shown as a popup. We can use the JavaScriptExecutor to do scroll to Element, but that seems to work only at the window level but not at the div level.

Upvotes: 7

Views: 16389

Answers (1)

Sitam Jana
Sitam Jana

Reputation: 3129

// Initialize Javascript executor
JavascriptExecutor js = (JavascriptExecutor) driver;

// Scroll inside web element vertically (e.g. 100 pixel)
js.executeScript("arguments[0].scrollTop = arguments[1];",driver.findElement(By.id("<div-id>")), 100);

This should help to scroll within DIV element.

Upvotes: 10

Related Questions