Skip to content

Instantly share code, notes, and snippets.

@matheuscdo
Forked from dariodiaz/highlight_sel_element.py
Created October 19, 2022 17:11
Show Gist options
  • Save matheuscdo/a36e1d268d48a3cc757611b6e5b5893d to your computer and use it in GitHub Desktop.
Save matheuscdo/a36e1d268d48a3cc757611b6e5b5893d 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