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)
@Gexar
Copy link

Gexar commented Oct 22, 2019

Thank you very much!

@roshansukur
Copy link

thanks a ton! very useful...

@klinsc
Copy link

klinsc commented Jan 12, 2020

This's Awesome!

@kerajel
Copy link

kerajel commented May 13, 2020

8 years in, still amazing, thanks!

@erenjaeger123456
Copy link

urakoze cyane

@pandeyshashank7
Copy link

can someone provide the screenshot of how it looks?

@ulfgj
Copy link

ulfgj commented Apr 6, 2021

._patent say what?

@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