@@ -698,8 +698,8 @@ def activate_jquery(self):
698
698
'''script.src = "http://code.jquery.com/jquery-3.2.1.min.js"; '''
699
699
'''document.getElementsByTagName("head")[0]'''
700
700
'''.appendChild(script);''' )
701
- for x in range (30 ):
702
- # jQuery needs a small amount of time to activate. (At most 3s)
701
+ for x in range (int ( settings . MINI_TIMEOUT * 10.0 ) ):
702
+ # jQuery needs a small amount of time to activate.
703
703
try :
704
704
self .execute_script ("jQuery('html')" )
705
705
return
@@ -779,9 +779,12 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
779
779
try :
780
780
selector = self .convert_to_css_selector (selector , by = by )
781
781
except Exception :
782
- # Don't highlight if can't convert to CSS_SELECTOR for jQuery
782
+ # Don't highlight if can't convert to CSS_SELECTOR
783
783
return
784
- selector = self ._make_css_match_first_element_only (selector )
784
+
785
+ if self .highlights :
786
+ loops = self .highlights
787
+ loops = int (loops )
785
788
786
789
o_bs = '' # original_box_shadow
787
790
style = element .get_attribute ('style' )
@@ -792,13 +795,66 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
792
795
original_box_shadow = style [box_start :box_end ]
793
796
o_bs = original_box_shadow
794
797
798
+ if ":contains" not in selector and ":first" not in selector :
799
+ selector = self .jq_format (selector )
800
+ self .__highlight_with_js (selector , loops , scroll , o_bs )
801
+ else :
802
+ selector = self ._make_css_match_first_element_only (selector )
803
+ selector = self .jq_format (selector )
804
+ try :
805
+ self .__highlight_with_jquery (selector , loops , scroll , o_bs )
806
+ except Exception :
807
+ pass # JQuery probably couldn't load. Skip highlighting.
808
+ time .sleep (0.065 )
809
+
810
+ def __highlight_with_js (self , selector , loops , scroll , o_bs ):
811
+ script = ("""document.querySelector('%s').style =
812
+ 'box-shadow: 0px 0px 6px 6px rgba(128, 128, 128, 0.5)';"""
813
+ % selector )
814
+ self .execute_script (script )
815
+
816
+ for n in range (loops ):
817
+ script = ("""document.querySelector('%s').style =
818
+ 'box-shadow: 0px 0px 6px 6px rgba(255, 0, 0, 1)';"""
819
+ % selector )
820
+ self .execute_script (script )
821
+ time .sleep (0.02 )
822
+ script = ("""document.querySelector('%s').style =
823
+ 'box-shadow: 0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
824
+ % selector )
825
+ self .execute_script (script )
826
+ time .sleep (0.02 )
827
+ script = ("""document.querySelector('%s').style =
828
+ 'box-shadow: 0px 0px 6px 6px rgba(0, 0, 255, 1)';"""
829
+ % selector )
830
+ self .execute_script (script )
831
+ time .sleep (0.02 )
832
+ script = ("""document.querySelector('%s').style =
833
+ 'box-shadow: 0px 0px 6px 6px rgba(0, 255, 0, 1)';"""
834
+ % selector )
835
+ self .execute_script (script )
836
+ time .sleep (0.02 )
837
+ script = ("""document.querySelector('%s').style =
838
+ 'box-shadow: 0px 0px 6px 6px rgba(128, 128, 0, 1)';"""
839
+ % selector )
840
+ self .execute_script (script )
841
+ time .sleep (0.02 )
842
+ script = ("""document.querySelector('%s').style =
843
+ 'box-shadow: 0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
844
+ % selector )
845
+ self .execute_script (script )
846
+ time .sleep (0.02 )
847
+
848
+ script = ("""document.querySelector('%s').style =
849
+ 'box-shadow: %s';"""
850
+ % (selector , o_bs ))
851
+ self .execute_script (script )
852
+
853
+ def __highlight_with_jquery (self , selector , loops , scroll , o_bs ):
795
854
script = """jQuery('%s').css('box-shadow',
796
855
'0px 0px 6px 6px rgba(128, 128, 128, 0.5)');""" % selector
797
856
self .safe_execute_script (script )
798
857
799
- if self .highlights :
800
- loops = self .highlights
801
- loops = int (loops )
802
858
for n in range (loops ):
803
859
script = """jQuery('%s').css('box-shadow',
804
860
'0px 0px 6px 6px rgba(255, 0, 0, 1)');""" % selector
@@ -827,7 +883,6 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
827
883
828
884
script = """jQuery('%s').css('box-shadow', '%s');""" % (selector , o_bs )
829
885
self .execute_script (script )
830
- time .sleep (0.065 )
831
886
832
887
def scroll_to (self , selector , by = By .CSS_SELECTOR ,
833
888
timeout = settings .SMALL_TIMEOUT ):
@@ -1376,7 +1431,7 @@ def wait_for_ready_state_complete(self, timeout=settings.EXTREME_TIMEOUT):
1376
1431
timeout = self ._get_new_timeout (timeout )
1377
1432
is_ready = page_actions .wait_for_ready_state_complete (self .driver ,
1378
1433
timeout )
1379
- self .wait_for_angularjs ()
1434
+ self .wait_for_angularjs (timeout = settings . MINI_TIMEOUT )
1380
1435
return is_ready
1381
1436
1382
1437
def wait_for_angularjs (self , timeout = settings .LARGE_TIMEOUT , ** kwargs ):
0 commit comments