For driver.highlight() / driver.page.highlight()
(driver, selector, by="css selector", loops=4)
| 401 | |
| 402 | |
| 403 | def 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 | |
| 425 | def highlight_with_js(driver, selector, loops=4, o_bs=""): |
nothing calls this directly
no test coverage detected