Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 737
Prabhu R Avatar asked Mar 28 '14 09:03

Prabhu R


1 Answers

// 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.

like image 77
Sitam Jana Avatar answered Sep 21 '22 17:09

Sitam Jana