@@ -279,7 +279,7 @@ def if_else_log_for_actions(left, next_level_step_data, statement="if"):
279279 return left + ".... condition matched\n " + "Running actions: " + log_actions
280280
281281
282- def If_else_action (step_data , data_set_no ):
282+ async def If_else_action (step_data , data_set_no ):
283283 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
284284 try :
285285 data_set = step_data [data_set_no ]
@@ -526,7 +526,7 @@ def check_operators():
526526 )
527527 return "zeuz_failed"
528528 if data_set_index not in inner_skip :
529- result , skip = Run_Sequential_Actions (
529+ result , skip = await Run_Sequential_Actions (
530530 [data_set_index ]
531531 ) # Running
532532 inner_skip = list (set (inner_skip + skip ))
@@ -559,7 +559,7 @@ def sanitize_deprecated_dataset(value):
559559 return value
560560
561561
562- def for_loop_action (step_data , data_set_no ):
562+ async def for_loop_action (step_data , data_set_no ):
563563 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
564564 try :
565565 data_set = step_data [data_set_no ]
@@ -748,7 +748,7 @@ def for_loop_action(step_data, data_set_no):
748748 sr .Set_Shared_Variables (CommonUtil .dont_prettify_on_server [0 ], step_data , protected = True , pretty = False )
749749 sr .test_action_info = CommonUtil .all_action_info [step_index ]
750750 return "zeuz_failed" , outer_skip
751- result , skip = Run_Sequential_Actions ([data_set_index ])
751+ result , skip = await Run_Sequential_Actions ([data_set_index ])
752752 inner_skip = list (set (inner_skip + skip ))
753753 outer_skip = list (set (outer_skip + inner_skip ))
754754
@@ -848,7 +848,7 @@ def for_loop_action(step_data, data_set_no):
848848 return CommonUtil .Exception_Handler (sys .exc_info ()), []
849849
850850
851- def While_Loop_Action (step_data , data_set_no ):
851+ async def While_Loop_Action (step_data , data_set_no ):
852852 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
853853 try :
854854 data_set = step_data [data_set_no ]
@@ -947,7 +947,7 @@ def While_Loop_Action(step_data, data_set_no):
947947 3
948948 )
949949 return "zeuz_failed" , outer_skip
950- result , skip = Run_Sequential_Actions (
950+ result , skip = await Run_Sequential_Actions (
951951 [data_set_index ]
952952 ) # new edit: full step data is passed. [step_data[data_set_index]])
953953 # Recursively call this function until all called data sets are complete
@@ -1049,7 +1049,7 @@ def ticker_linear_shape(seconds, callable, *args, **kwargs):
10491049 seconds -= 1
10501050
10511051
1052- def Sequential_Actions (
1052+ async def Sequential_Actions (
10531053 step_data ,
10541054 test_action_info ,
10551055 debug_actions = None ,
@@ -1068,13 +1068,13 @@ def Sequential_Actions(
10681068 # sr.Set_Shared_Variables("test_action_info", test_action_info, protected=True, print_variable=False)
10691069 sr .test_action_info = test_action_info
10701070
1071- result , skip_for_loop = Run_Sequential_Actions ([], debug_actions )
1071+ result , skip_for_loop = await Run_Sequential_Actions ([], debug_actions )
10721072 # empty list means run all, instead of step data we want to send the dataset no's of the step data to run
10731073 write_browser_logs ()
10741074 return result
10751075
10761076
1077- def Run_Sequential_Actions (
1077+ async def Run_Sequential_Actions (
10781078 data_set_list = None , debug_actions = None
10791079): # data_set_no will used in recursive conditional action call
10801080 if data_set_list is None :
@@ -1100,7 +1100,7 @@ def Run_Sequential_Actions(
11001100 data_set_list .append (i )
11011101
11021102 if len (data_set_list ) == 0 and CommonUtil .debug_status and not sr .Test_Shared_Variables ("selenium_driver" ) and ConfigModule .get_config_value ("Inspector" , "ai_plugin" ).strip ().lower () in CommonUtil .affirmative_words :
1103- return Action_Handler ([["browser" , "selenium action" , "browser" ]], ["browser" , "selenium action" , "browser" ]), []
1103+ return await Action_Handler ([["browser" , "selenium action" , "browser" ]], ["browser" , "selenium action" , "browser" ]), []
11041104
11051105 for dataset_cnt in data_set_list : # For each data set within step data
11061106 data_set = step_data [dataset_cnt ] # Save data set to variable
@@ -1196,15 +1196,15 @@ def Run_Sequential_Actions(
11961196
11971197 # If middle column = action, call action handler, but always return a pass
11981198 elif "optional action" in action_name :
1199- result = Action_Handler (data_set , row ) # Pass data set, and action_name to action handler
1199+ result = await Action_Handler (data_set , row ) # Pass data set, and action_name to action handler
12001200 if result == "zeuz_failed" :
12011201 CommonUtil .ExecLog (sModuleInfo , "Optional action failed. Returning pass anyway" , 2 )
12021202 result = "passed"
12031203
12041204 # If middle column = conditional action, evaluate data set
12051205 elif "conditional action" in action_name or "if else" in action_name :
12061206 if action_name .lower ().strip () == "windows conditional action" :
1207- result , to_skip = Conditional_Action_Handler (step_data , dataset_cnt )
1207+ result , to_skip = await Conditional_Action_Handler (step_data , dataset_cnt )
12081208 skip += to_skip
12091209 skip_for_loop += to_skip
12101210 if result in failed_tag_list :
@@ -1215,7 +1215,7 @@ def Run_Sequential_Actions(
12151215
12161216 elif action_name .lower ().strip () != "conditional action" and action_name .lower ().strip () != "if else" :
12171217 # old style conditional action
1218- result , to_skip = Conditional_Action_Handler (step_data , dataset_cnt )
1218+ result , to_skip = await Conditional_Action_Handler (step_data , dataset_cnt )
12191219 skip += to_skip
12201220 skip_for_loop += to_skip
12211221 if result in failed_tag_list :
@@ -1224,7 +1224,7 @@ def Run_Sequential_Actions(
12241224 break
12251225
12261226 else :
1227- result , to_skip = If_else_action (step_data , dataset_cnt )
1227+ result , to_skip = await If_else_action (step_data , dataset_cnt )
12281228 skip += to_skip
12291229 skip_for_loop += to_skip
12301230 if result in failed_tag_list :
@@ -1235,15 +1235,15 @@ def Run_Sequential_Actions(
12351235 # Simulate a while/for loop with the specified data sets
12361236 elif "loop action" in action_name :
12371237 if action_name .lower ().strip () == "for loop action" :
1238- result , skip_for_loop = for_loop_action (step_data , dataset_cnt )
1238+ result , skip_for_loop = await for_loop_action (step_data , dataset_cnt )
12391239 skip = list (set (skip + skip_for_loop ))
12401240 if result in failed_tag_list :
12411241 return "zeuz_failed" , skip_for_loop
12421242 break
12431243 elif action_name .lower ().strip () not in ("while loop action" , "for loop action" ):
12441244 # old style loop action
12451245 # CommonUtil.ExecLog(sModuleInfo,"Old style loop action found. This will not be supported in 2020, please replace them with new loop actions",2)
1246- result , skip_for_loop = Loop_Action_Handler (data_set , row , dataset_cnt )
1246+ result , skip_for_loop = await Loop_Action_Handler (data_set , row , dataset_cnt )
12471247 skip = skip_for_loop
12481248
12491249 position_of_loop_action = dataset_cnt
@@ -1273,7 +1273,7 @@ def Run_Sequential_Actions(
12731273 return "zeuz_failed" , skip_for_loop
12741274 elif "loop" in action_name :
12751275 if "while" in action_name .lower ():
1276- result , skip_for_loop = While_Loop_Action (step_data , dataset_cnt )
1276+ result , skip_for_loop = await While_Loop_Action (step_data , dataset_cnt )
12771277 skip = list (set (skip + skip_for_loop ))
12781278 if result in failed_tag_list :
12791279 return "zeuz_failed" , skip_for_loop
@@ -1343,7 +1343,7 @@ def Run_Sequential_Actions(
13431343
13441344 # If middle column = action, call action handler
13451345 elif "action" in action_name : # Must be last, since it's a single word that also exists in other action types
1346- result = Action_Handler (data_set , row ) # Pass data set, and action_name to action handler
1346+ result = await Action_Handler (data_set , row ) # Pass data set, and action_name to action handler
13471347 if row [0 ].lower ().strip () in ("step exit" , "testcase exit" ):
13481348 global step_exit_fail_called , step_exit_pass_called
13491349 CommonUtil .ExecLog (sModuleInfo , f"{ row [0 ].lower ().strip ()} Exit called. Stopping Test Step." , 1 )
@@ -1373,12 +1373,12 @@ def Run_Sequential_Actions(
13731373 continue
13741374
13751375 CommonUtil .ExecLog (sModuleInfo , "Action failed. Trying bypass #%d" % (i + 1 ), 1 )
1376- result = Action_Handler (bypass_data_set [i ], bypass_row [i ])
1376+ result = await Action_Handler (bypass_data_set [i ], bypass_row [i ])
13771377 if result in failed_tag_list : # This also failed, so chances are first failure was real
13781378 continue # Try the next bypass, if any
13791379 else : # Bypass passed, which indicates there was something blocking the element in the first place
13801380 CommonUtil .ExecLog (sModuleInfo , "Bypass passed. Retrying original action" , 1 )
1381- result = Action_Handler (data_set , row ) # Retry failed original data set
1381+ result = await Action_Handler (data_set , row ) # Retry failed original data set
13821382 if result in failed_tag_list : # Still a failure, give up
13831383 return "zeuz_failed" , skip_for_loop
13841384 break # No need to process more bypasses
@@ -1404,7 +1404,7 @@ def Run_Sequential_Actions(
14041404 return CommonUtil .Exception_Handler (sys .exc_info ())
14051405
14061406
1407- def Loop_Action_Handler (data , row , dataset_cnt ):
1407+ async def Loop_Action_Handler (data , row , dataset_cnt ):
14081408 """ Performs a sub-set of the data set in a loop, similar to a for or while loop """
14091409
14101410 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
@@ -1903,7 +1903,7 @@ def build_subset(new_step_data):
19031903 return CommonUtil .Exception_Handler (sys .exc_info ())
19041904
19051905
1906- def Conditional_Action_Handler (step_data , dataset_cnt ):
1906+ async def Conditional_Action_Handler (step_data , dataset_cnt ):
19071907 """ Process conditional actions, called only by Sequential_Actions() """
19081908 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
19091909
@@ -2296,7 +2296,7 @@ def compare_variable_names(set, dataset):
22962296 CommonUtil .compare_action_varnames = {"left" : "Left" , "right" : "Right" }
22972297
22982298
2299- def Action_Handler (_data_set , action_row , _bypass_bug = True ):
2299+ async def Action_Handler (_data_set , action_row , _bypass_bug = True ):
23002300 """ Finds the appropriate function for the requested action in the step data and executes it """
23012301
23022302 sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
@@ -2417,6 +2417,8 @@ def Action_Handler(_data_set, action_row, _bypass_bug=True):
24172417 elif module in CommonUtil .global_sleep and "_all_" in CommonUtil .global_sleep [module ]:
24182418 time .sleep (CommonUtil .global_sleep [module ]["_all_" ]["pre" ])
24192419 result = run_function (data_set ) # Execute function, providing all rows in the data set
2420+ if inspect .iscoroutine (result ):
2421+ result = await result
24202422 if post_sleep :
24212423 time .sleep (post_sleep )
24222424 elif module in CommonUtil .global_sleep and "_all_" in CommonUtil .global_sleep [module ]:
0 commit comments