Skip to content

Instantly share code, notes, and snippets.

@y3rsh
Last active August 29, 2015 14:27
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 y3rsh/b3ce9969bfb4ff960d91 to your computer and use it in GitHub Desktop.
Save y3rsh/b3ce9969bfb4ff960d91 to your computer and use it in GitHub Desktop.
/// <summary>
/// Highlight an element for a time
/// Useful in debugging/demos
/// </summary>
/// <param name="element">the element to highlight</param>
/// <param name="time">time to highlight before returning to normal</param>
public static void HighlightElement(IWebElement element, int highlightTimeMilliseconds = 5000)
{
IJavaScriptExecutor js = TestRunner.Driver as IJavaScriptExecutor;
String oldStyle = element.GetAttribute("style");
String args = "arguments[0].setAttribute('style', arguments[1]);";
js.ExecuteScript(args, element, "border: 4px solid yellow;display:block;");
Thread.Sleep(highlightTimeMilliseconds);
js.ExecuteScript(args, element, oldStyle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment