@@ -3273,7 +3273,7 @@ def __process_recorded_actions(self):
3273
3273
and srt_actions [n - 1 ][0 ] == "chfil"
3274
3274
):
3275
3275
srt_actions [n - 1 ][0 ] = "_skip"
3276
- srt_actions [n ][2 ] = srt_actions [n - 1 ][1 ]
3276
+ srt_actions [n ][2 ] = srt_actions [n - 1 ][1 ][ 1 ]
3277
3277
origins = []
3278
3278
for n in range (len (srt_actions )):
3279
3279
if (
@@ -3297,6 +3297,18 @@ def __process_recorded_actions(self):
3297
3297
srt_actions [n ][0 ] = "h_clk"
3298
3298
srt_actions [n ][1 ] = srt_actions [n - 1 ][1 ][0 ]
3299
3299
srt_actions [n ][2 ] = srt_actions [n - 1 ][1 ][1 ]
3300
+ for n in range (len (srt_actions )):
3301
+ if srt_actions [n ][0 ] == "chfil" and srt_actions [n ][2 ] in origins :
3302
+ srt_actions [n ][0 ] = "cho_f"
3303
+ srt_actions [n ][2 ] = srt_actions [n ][1 ][1 ]
3304
+ srt_actions [n ][1 ] = srt_actions [n ][1 ][0 ]
3305
+ for n in range (len (srt_actions )):
3306
+ if (
3307
+ srt_actions [n ][0 ] == "sh_fc"
3308
+ and n > 0
3309
+ and srt_actions [n - 1 ][0 ] == "sh_fc"
3310
+ ):
3311
+ srt_actions [n - 1 ][0 ] = "_skip"
3300
3312
ext_actions = []
3301
3313
ext_actions .append ("js_cl" )
3302
3314
ext_actions .append ("as_el" )
@@ -3312,6 +3324,7 @@ def __process_recorded_actions(self):
3312
3324
ext_actions .append ("sw_dc" )
3313
3325
ext_actions .append ("s_c_f" )
3314
3326
ext_actions .append ("s_c_d" )
3327
+ ext_actions .append ("sh_fc" )
3315
3328
for n in range (len (srt_actions )):
3316
3329
if srt_actions [n ][0 ] in ext_actions :
3317
3330
origin = srt_actions [n ][2 ]
@@ -3521,6 +3534,9 @@ def __process_recorded_actions(self):
3521
3534
else :
3522
3535
sb_actions .append ("self.%s('%s')" % (
3523
3536
method , action [1 ][0 ]))
3537
+ elif action [0 ] == "sh_fc" :
3538
+ cb_method = "show_file_choosers"
3539
+ sb_actions .append ('self.%s()' % cb_method )
3524
3540
elif action [0 ] == "c_box" :
3525
3541
cb_method = "check_if_unchecked"
3526
3542
if action [2 ] == "no" :
@@ -4120,6 +4136,15 @@ def show_file_choosers(self):
4120
4136
self .execute_script (script )
4121
4137
except Exception :
4122
4138
pass
4139
+ if self .recorder_mode :
4140
+ url = self .get_current_url ()
4141
+ if url and len (url ) > 0 :
4142
+ if ("http:" ) in url or ("https:" ) in url or ("file:" ) in url :
4143
+ if self .get_session_storage_item ("pause_recorder" ) == "no" :
4144
+ time_stamp = self .execute_script ("return Date.now();" )
4145
+ origin = self .get_origin ()
4146
+ action = ["sh_fc" , "" , origin , time_stamp ]
4147
+ self .__extra_actions .append (action )
4123
4148
4124
4149
def get_domain_url (self , url ):
4125
4150
self .__check_scope ()
@@ -4440,6 +4465,15 @@ def choose_file(
4440
4465
self .__demo_mode_highlight_if_active (selector , by )
4441
4466
if not self .demo_mode and not self .slow_mode :
4442
4467
self .__scroll_to_element (element , selector , by )
4468
+ else :
4469
+ choose_file_selector = 'input[type="file"]'
4470
+ if self .is_element_present (choose_file_selector ):
4471
+ if not self .is_element_visible (choose_file_selector ):
4472
+ self .show_file_choosers ()
4473
+ if self .is_element_visible (selector , by = by ):
4474
+ self .__demo_mode_highlight_if_active (selector , by )
4475
+ if not self .demo_mode and not self .slow_mode :
4476
+ self .__scroll_to_element (element , selector , by )
4443
4477
pre_action_url = self .driver .current_url
4444
4478
if self .recorder_mode :
4445
4479
url = self .get_current_url ()
@@ -4448,7 +4482,8 @@ def choose_file(
4448
4482
if self .get_session_storage_item ("pause_recorder" ) == "no" :
4449
4483
time_stamp = self .execute_script ("return Date.now();" )
4450
4484
origin = self .get_origin ()
4451
- action = ["chfil" , file_path , origin , time_stamp ]
4485
+ sele_file_path = [selector , file_path ]
4486
+ action = ["chfil" , sele_file_path , origin , time_stamp ]
4452
4487
self .__extra_actions .append (action )
4453
4488
if type (abs_path ) is int or type (abs_path ) is float :
4454
4489
abs_path = str (abs_path )
0 commit comments