Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dariodiaz/3104601 to your computer and use it in GitHub Desktop.
Save dariodiaz/3104601 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)
@matheuscdo
Copy link

Such a helpfull code! Thanks a lot!

@Sendery
Copy link

Sendery commented Jan 31, 2023

Thanks,
I did add a seccond loop to make it blink...
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment