Created
July 10, 2012 22:10
-
-
Save marciomazza/3086536 to your computer and use it in GitHub Desktop.
Highlights a Selenium Webdriver element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def highlight(element): | |
"""Highlights (blinks) a Webdriver element. | |
In pure javascript, as suggested by https://github.com/alp82. | |
""" | |
driver = element._parent | |
driver.execute_script(""" | |
element = arguments[0]; | |
original_style = element.getAttribute('style'); | |
element.setAttribute('style', original_style + "; background: yellow; border: 2px solid red;"); | |
setTimeout(function(){ | |
element.setAttribute('style', original_style); | |
}, 300); | |
""", element) |
Here you can find how to highlight element using selenium web driver with example:
http://www.testingdiaries.com/highlight-element-using-selenium-webdriver/
Big up for this trick!
Big thanks for this!
Thanks - Is there a license with this code?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do I call this function in ruby selenium webdriver?
i tried: driver.highlight(:css,"input[name='email']")
but it didn't work.