> For the complete documentation index, see [llms.txt](https://n-saikiran.gitbook.io/selenium-2-web-driver-basics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://n-saikiran.gitbook.io/selenium-2-web-driver-basics/4.-selenium-prospects/4.5-javascript-executor.md).

# 4.5 Javascript executor

It’s possible to execute your custom JavaScript on a webpage. The code below helps in scrolling the page.

```
@Test
/**
 * Function to perform a scroll down for the page with a time delay of 50ms
 * window.scrollBy(0,500) - Horizontal and vertical scroll increments
 * setTimeout('pageScroll()',50) - scrolls every 50 milliseconds
 * @author saikiran
 */
public void pageScroll() {
    driver.get("http://someURl.com");
    // invoke javascript executor
    JavascriptExecutor executor = (JavascriptExecutor) driver;
    executor.executeScript("window.scrollBy(0,500);scrolldelay = setTimeout('pageScroll()',50);");
}
```
