Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created February 20, 2016 11:16
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/ff0975c675a261fb58ed to your computer and use it in GitHub Desktop.
Save angelovstanton/ff0975c675a261fb58ed to your computer and use it in GitHub Desktop.
[TestMethod]
public void FocusOnControl()
{
this.driver.Navigate().GoToUrl(
@"http://automatetheplanet.com/compelling-sunday-14022016/");
IWebElement link = driver.FindElement(By.PartialLinkText("Previous post"));
// 9.1. Option 1.
link.SendKeys(string.Empty);
// 9.1. Option 2.
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].focus();", link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment