(driver, selector, loops=4, o_bs="")
| 595 | |
| 596 | |
| 597 | def highlight_with_jquery(driver, selector, loops=4, o_bs=""): |
| 598 | with suppress(Exception): |
| 599 | # This closes any pop-up alerts |
| 600 | execute_script(driver, "") |
| 601 | if selector == "html": |
| 602 | selector = "body" |
| 603 | selector_no_spaces = selector.replace(" ", "") |
| 604 | early_exit = False |
| 605 | if '[style=\\"' in selector_no_spaces: |
| 606 | if "box\\-shadow:" in selector: |
| 607 | early_exit = True # Changing the box-shadow changes the selector |
| 608 | elif '[style=\\"' in selector: |
| 609 | selector = selector.replace('[style=\\"', '[style\\*=\\"') |
| 610 | else: |
| 611 | early_exit = True # Changing the box-shadow changes the selector |
| 612 | if early_exit: |
| 613 | return |
| 614 | script = ( |
| 615 | """jQuery('%s').css('box-shadow', |
| 616 | '0px 0px 6px 6px rgba(128, 128, 128, 0.5)');""" |
| 617 | % selector |
| 618 | ) |
| 619 | with suppress(Exception): |
| 620 | safe_execute_script(driver, script) |
| 621 | for n in range(loops): |
| 622 | script = ( |
| 623 | """jQuery('%s').css('box-shadow', |
| 624 | '0px 0px 6px 6px rgba(255, 0, 0, 1)');""" |
| 625 | % selector |
| 626 | ) |
| 627 | with suppress(Exception): |
| 628 | execute_script(driver, script) |
| 629 | time.sleep(0.0181) |
| 630 | script = ( |
| 631 | """jQuery('%s').css('box-shadow', |
| 632 | '0px 0px 6px 6px rgba(128, 0, 128, 1)');""" |
| 633 | % selector |
| 634 | ) |
| 635 | with suppress(Exception): |
| 636 | execute_script(driver, script) |
| 637 | time.sleep(0.0181) |
| 638 | script = ( |
| 639 | """jQuery('%s').css('box-shadow', |
| 640 | '0px 0px 6px 6px rgba(0, 0, 255, 1)');""" |
| 641 | % selector |
| 642 | ) |
| 643 | with suppress(Exception): |
| 644 | execute_script(driver, script) |
| 645 | time.sleep(0.0181) |
| 646 | script = ( |
| 647 | """jQuery('%s').css('box-shadow', |
| 648 | '0px 0px 6px 6px rgba(0, 255, 0, 1)');""" |
| 649 | % selector |
| 650 | ) |
| 651 | with suppress(Exception): |
| 652 | execute_script(driver, script) |
| 653 | time.sleep(0.0181) |
| 654 | script = ( |
nothing calls this directly
no test coverage detected
searching dependent graphs…