@@ -96,6 +96,7 @@ def __init__(self, *args, **kwargs):
96
96
self .__last_page_url = None
97
97
self .__last_page_source = None
98
98
self .__skip_reason = None
99
+ self .__dont_record_js_click = False
99
100
self .__overrided_default_timeouts = False
100
101
self .__added_pytest_html_extra = None
101
102
self .__deferred_assert_count = 0
@@ -1659,7 +1660,9 @@ def check_if_unchecked(self, selector, by=By.CSS_SELECTOR):
1659
1660
self .click (selector , by = by )
1660
1661
else :
1661
1662
selector = self .convert_to_css_selector (selector , by = by )
1663
+ self .__dont_record_js_click = True
1662
1664
self .js_click (selector , by = By .CSS_SELECTOR )
1665
+ self .__dont_record_js_click = False
1663
1666
1664
1667
def select_if_unselected (self , selector , by = By .CSS_SELECTOR ):
1665
1668
""" Same as check_if_unchecked() """
@@ -1674,7 +1677,9 @@ def uncheck_if_checked(self, selector, by=By.CSS_SELECTOR):
1674
1677
self .click (selector , by = by )
1675
1678
else :
1676
1679
selector = self .convert_to_css_selector (selector , by = by )
1680
+ self .__dont_record_js_click = True
1677
1681
self .js_click (selector , by = By .CSS_SELECTOR )
1682
+ self .__dont_record_js_click = False
1678
1683
1679
1684
def unselect_if_selected (self , selector , by = By .CSS_SELECTOR ):
1680
1685
""" Same as uncheck_if_checked() """
@@ -1860,7 +1865,9 @@ def hover_and_click(
1860
1865
self .__get_href_from_partial_link_text (click_selector )
1861
1866
)
1862
1867
else :
1868
+ self .__dont_record_js_click = True
1863
1869
self .js_click (click_selector , by = click_by )
1870
+ self .__dont_record_js_click = False
1864
1871
if outdated_driver :
1865
1872
pass # Already did the click workaround
1866
1873
elif self .mobile_emulator :
@@ -1943,7 +1950,9 @@ def hover_and_double_click(
1943
1950
self .__get_href_from_partial_link_text (click_selector )
1944
1951
)
1945
1952
else :
1953
+ self .__dont_record_js_click = True
1946
1954
self .js_click (click_selector , click_by )
1955
+ self .__dont_record_js_click = False
1947
1956
if not outdated_driver :
1948
1957
element = page_actions .hover_element_and_double_click (
1949
1958
self .driver ,
@@ -3214,15 +3223,23 @@ def __process_recorded_actions(self):
3214
3223
and (
3215
3224
srt_actions [n - 1 ][0 ] == "click"
3216
3225
or srt_actions [n - 1 ][0 ] == "js_cl"
3226
+ or srt_actions [n - 1 ][0 ] == "js_ca"
3217
3227
)
3218
3228
):
3219
3229
url1 = srt_actions [n - 1 ][2 ]
3220
- if srt_actions [n - 1 ][0 ] == "js_cl" :
3230
+ if (
3231
+ srt_actions [n - 1 ][0 ] == "js_cl"
3232
+ or srt_actions [n - 1 ][0 ] == "js_ca"
3233
+ ):
3221
3234
url1 = srt_actions [n - 1 ][2 ][0 ]
3222
- if url1 .endswith ("/" ):
3235
+ if url1 .endswith ("/#/" ):
3236
+ url1 = url1 [:- 3 ]
3237
+ elif url1 .endswith ("/" ):
3223
3238
url1 = url1 [:- 1 ]
3224
3239
url2 = srt_actions [n ][2 ]
3225
- if url2 .endswith ("/" ):
3240
+ if url2 .endswith ("/#/" ):
3241
+ url2 = url1 [:- 3 ]
3242
+ elif url2 .endswith ("/" ):
3226
3243
url2 = url2 [:- 1 ]
3227
3244
if url1 == url2 :
3228
3245
srt_actions [n ][0 ] = "f_url"
@@ -3236,10 +3253,14 @@ def __process_recorded_actions(self):
3236
3253
)
3237
3254
):
3238
3255
url1 = srt_actions [n - 1 ][2 ]
3239
- if url1 .endswith ("/" ):
3256
+ if url1 .endswith ("/#/" ):
3257
+ url1 = url1 [:- 3 ]
3258
+ elif url1 .endswith ("/" ):
3240
3259
url1 = url1 [:- 1 ]
3241
3260
url2 = srt_actions [n ][2 ]
3242
- if url2 .endswith ("/" ):
3261
+ if url2 .endswith ("/#/" ):
3262
+ url2 = url1 [:- 3 ]
3263
+ elif url2 .endswith ("/" ):
3243
3264
url2 = url2 [:- 1 ]
3244
3265
if url1 == url2 :
3245
3266
srt_actions [n - 1 ][0 ] = "_skip"
@@ -3250,13 +3271,15 @@ def __process_recorded_actions(self):
3250
3271
and (
3251
3272
srt_actions [n - 1 ][0 ] == "click"
3252
3273
or srt_actions [n - 1 ][0 ] == "js_cl"
3274
+ or srt_actions [n - 1 ][0 ] == "js_ca"
3253
3275
or srt_actions [n - 1 ][0 ] == "input"
3254
3276
)
3255
3277
and (int (srt_actions [n ][3 ]) - int (srt_actions [n - 1 ][3 ]) < 6500 )
3256
3278
):
3257
3279
if (
3258
3280
srt_actions [n - 1 ][0 ] == "click"
3259
3281
or srt_actions [n - 1 ][0 ] == "js_cl"
3282
+ or srt_actions [n - 1 ][0 ] == "js_ca"
3260
3283
):
3261
3284
if (
3262
3285
srt_actions [n - 1 ][1 ].startswith ("input" )
@@ -3311,6 +3334,7 @@ def __process_recorded_actions(self):
3311
3334
srt_actions [n - 1 ][0 ] = "_skip"
3312
3335
ext_actions = []
3313
3336
ext_actions .append ("js_cl" )
3337
+ ext_actions .append ("js_ca" )
3314
3338
ext_actions .append ("as_el" )
3315
3339
ext_actions .append ("as_ep" )
3316
3340
ext_actions .append ("asenv" )
@@ -3325,10 +3349,14 @@ def __process_recorded_actions(self):
3325
3349
ext_actions .append ("s_c_f" )
3326
3350
ext_actions .append ("s_c_d" )
3327
3351
ext_actions .append ("sh_fc" )
3352
+ ext_actions .append ("c_l_s" )
3328
3353
for n in range (len (srt_actions )):
3329
3354
if srt_actions [n ][0 ] in ext_actions :
3330
3355
origin = srt_actions [n ][2 ]
3331
- if srt_actions [n ][0 ] == "js_cl" :
3356
+ if (
3357
+ srt_actions [n ][0 ] == "js_cl"
3358
+ or srt_actions [n ][0 ] == "js_ca"
3359
+ ):
3332
3360
origin = srt_actions [n ][2 ][1 ]
3333
3361
if origin .endswith ("/" ):
3334
3362
origin = origin [0 :- 1 ]
@@ -3353,6 +3381,12 @@ def __process_recorded_actions(self):
3353
3381
sb_actions .append ('self.%s("%s")' % (method , action [1 ]))
3354
3382
else :
3355
3383
sb_actions .append ("self.%s('%s')" % (method , action [1 ]))
3384
+ elif action [0 ] == "js_ca" :
3385
+ method = "js_click_all"
3386
+ if '"' not in action [1 ]:
3387
+ sb_actions .append ('self.%s("%s")' % (method , action [1 ]))
3388
+ else :
3389
+ sb_actions .append ("self.%s('%s')" % (method , action [1 ]))
3356
3390
elif action [0 ] == "input" :
3357
3391
method = "type"
3358
3392
text = action [2 ].replace ("\n " , "\\ n" )
@@ -3537,6 +3571,8 @@ def __process_recorded_actions(self):
3537
3571
elif action [0 ] == "sh_fc" :
3538
3572
cb_method = "show_file_choosers"
3539
3573
sb_actions .append ('self.%s()' % cb_method )
3574
+ elif action [0 ] == "c_l_s" :
3575
+ sb_actions .append ("self.clear_local_storage()" )
3540
3576
elif action [0 ] == "c_box" :
3541
3577
cb_method = "check_if_unchecked"
3542
3578
if action [2 ] == "no" :
@@ -3963,7 +3999,7 @@ def js_click(
3963
3999
action = None
3964
4000
pre_action_url = self .driver .current_url
3965
4001
pre_window_count = len (self .driver .window_handles )
3966
- if self .recorder_mode :
4002
+ if self .recorder_mode and not self . __dont_record_js_click :
3967
4003
time_stamp = self .execute_script ("return Date.now();" )
3968
4004
tag_name = None
3969
4005
href = ""
@@ -3979,6 +4015,8 @@ def js_click(
3979
4015
origin = self .get_origin ()
3980
4016
href_origin = [href , origin ]
3981
4017
action = ["js_cl" , selector , href_origin , time_stamp ]
4018
+ if all_matches :
4019
+ action [0 ] = "js_ca"
3982
4020
if not all_matches :
3983
4021
if ":contains\\ (" not in css_selector :
3984
4022
self .__js_click (selector , by = by )
@@ -5786,6 +5824,11 @@ def remove_local_storage_item(self, key):
5786
5824
def clear_local_storage (self ):
5787
5825
self .__check_scope ()
5788
5826
self .execute_script ("window.localStorage.clear();" )
5827
+ if self .recorder_mode :
5828
+ time_stamp = self .execute_script ("return Date.now();" )
5829
+ origin = self .get_origin ()
5830
+ action = ["c_l_s" , "" , origin , time_stamp ]
5831
+ self .__extra_actions .append (action )
5789
5832
5790
5833
def get_local_storage_keys (self ):
5791
5834
self .__check_scope ()
0 commit comments