MCPcopy Index your code
hub / github.com/seleniumbase/SeleniumBase / highlight

Function highlight

seleniumbase/fixtures/js_utils.py:403–422  ·  view source on GitHub ↗

For driver.highlight() / driver.page.highlight()

(driver, selector, by="css selector", loops=4)

Source from the content-addressed store, hash-verified

401
402
403def highlight(driver, selector, by="css selector", loops=4):
404 """For driver.highlight() / driver.page.highlight()"""
405 swap_selector_and_by_if_reversed(selector, by)
406 if ":contains(" in selector:
407 by = "xpath"
408 selector = css_to_xpath.convert_css_to_xpath(selector)
409 element = None
410 try:
411 element = driver.find_element(by, selector)
412 except Exception:
413 time.sleep(1)
414 element = driver.find_element(by, selector)
415 o_bs = "" # original_box_shadow
416 style = element.get_attribute("style")
417 if style and "box-shadow: " in style:
418 box_start = style.find("box-shadow: ")
419 box_end = style.find(";", box_start) + 1
420 original_box_shadow = style[box_start:box_end]
421 o_bs = original_box_shadow
422 highlight_element_with_js(driver, element, loops=loops, o_bs=o_bs)
423
424
425def highlight_with_js(driver, selector, loops=4, o_bs=""):

Callers

nothing calls this directly

Calls 7

convert_css_to_xpathMethod · 0.80
findMethod · 0.80
find_elementMethod · 0.45
sleepMethod · 0.45
get_attributeMethod · 0.45

Tested by

no test coverage detected