Selenium Webdriver scrolling inside a popup

A tooltip will appear that has a lot of content that will need to be scrolled to view it fully. It was necessary to scroll through the contents in a div that appears as a popup. We can use the JavaScriptExecutor to scroll to the element, but this only works at the window level, but not at the div level.

+7
java selenium-webdriver
source share
1 answer
// Initialize Javascript executor JavascriptExecutor js = (JavascriptExecutor) driver; // Scroll inside web element vertically (eg 100 pixel) js.executeScript("arguments[0].scrollTop = arguments[1];",driver.findElement(By.id("<div-id>")), 100); 

This should help to scroll through the div element.

+10
source share

All Articles