Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save filipeandre/e2f43acc78110102d66980c871d68f2f to your computer and use it in GitHub Desktop.
Save filipeandre/e2f43acc78110102d66980c871d68f2f to your computer and use it in GitHub Desktop.
python: Highlights a Selenium Webdriver element
import time
def highlight(element):
"""Highlights (blinks) a Selenium Webdriver element"""
driver = element._parent
def apply_style(s):
driver.execute_script("arguments[0].setAttribute('style', arguments[1]);",
element, s)
original_style = element.get_attribute('style')
apply_style("background: yellow; border: 2px solid red;")
time.sleep(.3)
apply_style(original_style)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment