Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 20, 2016 11:12
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/af9d727d8e18672bb6dd to your computer and use it in GitHub Desktop.
Save angelovstanton/af9d727d8e18672bb6dd to your computer and use it in GitHub Desktop.
[TestMethod]
public void ScrollFocusToControl()
{
this.driver.Navigate().GoToUrl(@"http://automatetheplanet.com/compelling-sunday-14022016/");
IWebElement link = driver.FindElement(By.PartialLinkText("Previous post"));
string jsToBeExecuted = string.Format("window.scroll(0, {0});", link.Location.Y);
((IJavaScriptExecutor)driver).ExecuteScript(jsToBeExecuted);
link.Click();
Assert.AreEqual<string>("10 Advanced WebDriver Tips and Tricks - Part 1", driver.Title);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment