Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created August 20, 2020 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/305df84f47949d8126c9f3bf1e7fc914 to your computer and use it in GitHub Desktop.
Save angelovstanton/305df84f47949d8126c9f3bf1e7fc914 to your computer and use it in GitHub Desktop.
@Test
public void scrollFocusToControl() {
driver.navigate().to("http://automatetheplanet.com/");
var ourMissionLink = driver.findElement(By.xpath("//*[@id=\"panel-6435-0-0-4\"]/div"));
String jsToBeExecuted = String.format("window.scroll(0, {0});", ourMissionLink.getLocation().getY());
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
javascriptExecutor.executeScript(jsToBeExecuted);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment