@@ -3046,7 +3046,10 @@ def __process_recorded_actions(self):
3046
3046
if (
3047
3047
(srt_actions [n ][0 ] == "begin" or srt_actions [n ][0 ] == "_url_" )
3048
3048
and n > 0
3049
- and srt_actions [n - 1 ][0 ] == "click"
3049
+ and (
3050
+ srt_actions [n - 1 ][0 ] == "click"
3051
+ or srt_actions [n - 1 ][0 ] == "js_cl"
3052
+ )
3050
3053
):
3051
3054
url1 = srt_actions [n - 1 ][2 ]
3052
3055
if url1 .endswith ("/" ):
@@ -3079,11 +3082,15 @@ def __process_recorded_actions(self):
3079
3082
and n > 0
3080
3083
and (
3081
3084
srt_actions [n - 1 ][0 ] == "click"
3085
+ or srt_actions [n - 1 ][0 ] == "js_cl"
3082
3086
or srt_actions [n - 1 ][0 ] == "input"
3083
3087
)
3084
3088
and (int (srt_actions [n ][3 ]) - int (srt_actions [n - 1 ][3 ]) < 6500 )
3085
3089
):
3086
- if srt_actions [n - 1 ][0 ] == "click" :
3090
+ if (
3091
+ srt_actions [n - 1 ][0 ] == "click"
3092
+ or srt_actions [n - 1 ][0 ] == "js_cl"
3093
+ ):
3087
3094
if (
3088
3095
srt_actions [n - 1 ][1 ].startswith ("input" )
3089
3096
or srt_actions [n - 1 ][1 ].startswith ("button" )
@@ -3105,6 +3112,12 @@ def __process_recorded_actions(self):
3105
3112
sb_actions .append ('self.%s("%s")' % (method , action [1 ]))
3106
3113
else :
3107
3114
sb_actions .append ("self.%s('%s')" % (method , action [1 ]))
3115
+ elif action [0 ] == "js_cl" :
3116
+ method = "js_click"
3117
+ if '"' not in action [1 ]:
3118
+ sb_actions .append ('self.%s("%s")' % (method , action [1 ]))
3119
+ else :
3120
+ sb_actions .append ("self.%s('%s')" % (method , action [1 ]))
3108
3121
elif action [0 ] == "input" :
3109
3122
method = "type"
3110
3123
text = action [2 ].replace ("\n " , "\\ n" )
@@ -3679,6 +3692,23 @@ def js_click(
3679
3692
css_selector = self .convert_to_css_selector (selector , by = by )
3680
3693
css_selector = re .escape (css_selector ) # Add "\\" to special chars
3681
3694
css_selector = self .__escape_quotes_if_needed (css_selector )
3695
+ action = None
3696
+ pre_action_url = self .driver .current_url
3697
+ pre_window_count = len (self .driver .window_handles )
3698
+ if self .recorder_mode :
3699
+ time_stamp = self .execute_script ("return Date.now();" )
3700
+ tag_name = None
3701
+ href = ""
3702
+ if ":contains\\ (" not in css_selector :
3703
+ tag_name = self .execute_script (
3704
+ "return document.querySelector('%s').tagName.toLowerCase()"
3705
+ % css_selector
3706
+ )
3707
+ if tag_name == "a" :
3708
+ href = self .execute_script (
3709
+ "return document.querySelector('%s').href" % css_selector
3710
+ )
3711
+ action = ["js_cl" , selector , href , time_stamp ]
3682
3712
if not all_matches :
3683
3713
if ":contains\\ (" not in css_selector :
3684
3714
self .__js_click (selector , by = by )
0 commit comments