Paint a quickly-vanishing dot over an element.
(
self,
selector, # The CSS Selector to flash
duration=1, # (seconds) flash duration
color="44CC88", # RGB hex color string
pause=0, # (seconds) If 0, the next action starts during flash
)
| 6471 | self.execute_script(script) |
| 6472 | |
| 6473 | def flash( |
| 6474 | self, |
| 6475 | selector, # The CSS Selector to flash |
| 6476 | duration=1, # (seconds) flash duration |
| 6477 | color="44CC88", # RGB hex color string |
| 6478 | pause=0, # (seconds) If 0, the next action starts during flash |
| 6479 | ): |
| 6480 | """Paint a quickly-vanishing dot over an element.""" |
| 6481 | if self.__is_cdp_swap_needed(): |
| 6482 | self.cdp.flash( |
| 6483 | selector=selector, |
| 6484 | duration=duration, |
| 6485 | color=color, |
| 6486 | pause=pause, |
| 6487 | ) |
| 6488 | return |
| 6489 | element = self.find_element(selector, timeout=settings.SMALL_TIMEOUT) |
| 6490 | js_utils.scroll_to_element(self.driver, element) |
| 6491 | try: |
| 6492 | loc = element.location # {'x': value, 'y': value} |
| 6493 | size = element.size # {'width': value, 'height': value} |
| 6494 | center_x = loc["x"] + (size["width"] / 2) |
| 6495 | center_y = loc["y"] + (size["height"] / 2) |
| 6496 | except Exception: |
| 6497 | return |
| 6498 | style = ( |
| 6499 | "position:absolute;z-index:99999999;padding:0;margin:0;" |
| 6500 | "left:{:.1f}px; top: {:.1f}px; opacity:0.7;" |
| 6501 | "width:8px;height:8px;border-radius:50%;background:#{};" |
| 6502 | "animation:show-pointer-ani {:.2f}s ease 1;" |
| 6503 | ).format( |
| 6504 | center_x - 4, # -4 to account for the circle width |
| 6505 | center_y - 4, # -4 to account for the circle height |
| 6506 | color, |
| 6507 | duration, |
| 6508 | ) |
| 6509 | script = ( |
| 6510 | """ |
| 6511 | (targetElement) => {{ |
| 6512 | for(let css of [...document.styleSheets]) {{ |
| 6513 | try {{ |
| 6514 | css.insertRule(` |
| 6515 | @keyframes show-pointer-ani {{ |
| 6516 | 0% {{ opacity: 1; transform: scale(2, 2); }} |
| 6517 | 25% {{ transform: scale(5,5); }} |
| 6518 | 50% {{ transform: scale(3, 3); }} |
| 6519 | 75% {{ transform: scale(2,2); }} |
| 6520 | 100% {{ transform: scale(1, 1); opacity: 0; }} |
| 6521 | }}`, css.cssRules.length); |
| 6522 | break; |
| 6523 | }} catch (e) {{ |
| 6524 | console.log(e); |
| 6525 | }} |
| 6526 | }}; |
| 6527 | var _d = document.createElement('div'); |
| 6528 | _d.style = `{0:s}`; |
| 6529 | _d.id = `{1:s}`; |
| 6530 | document.body.insertAdjacentElement('afterBegin', _d); |
nothing calls this directly
no test coverage detected