Skip to content

Instantly share code, notes, and snippets.

@santhoshv339
Created January 23, 2017 12:13
Show Gist options
  • Save santhoshv339/085531e6b10da6e67036ac018e3ff350 to your computer and use it in GitHub Desktop.
Save santhoshv339/085531e6b10da6e67036ac018e3ff350 to your computer and use it in GitHub Desktop.
Scroll to a particular Element in view
// Create instance of Javascript executor
JavascriptExecutor je = (JavascriptExecutor) driver;
//Identify the WebElement which will appear after scrolling down
WebElement element = driver.findElement(By.xpath(""));
// now execute query which actually will scroll until that element is not appeared on page.
je.executeScript("arguments[0].scrollIntoView(true);",element); //or
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment