scroll until element is visible jquery code example

Example 1: how to scroll if element not visible

We can use javaScriptExecutor to scroll down
WebDriver driver = new ChromeDriver(); 
JavascriptExecutor jse =(JavascriptExecutor)driver
.jse.executeScript('window.scrollBy(0,250)', ’’);

Example 2: scroll down to element if not visible

WebDriver driver = new ChromeDriver(); 
JavascriptExecutor jse =(JavascriptExecutor)driver
.jse.executeScript('window.scrollBy(0,250)', ’’);