@@ -178,38 +178,56 @@ def write_browser_logs():
178178
179179
180180deprecateLog  =  True 
181- def  get_data_set_nums (action_value ):
181+ def  get_data_set_nums (action_value ,  step_loop = False ):
182182    try :
183+         action_value  =  action_value .replace (" " , "" ).replace ("_" , "" ).lower ()
183184        data_set_nums  =  []
184185        global  deprecateLog 
185-         if  "run"  in  action_value .lower () or  "#"  in  action_value .lower ():
186-             if  deprecateLog :
187-                 deprecateLog  =  False 
188-                 CommonUtil .ExecLog (
189-                     "" ,
190-                     "remove 'action#', 'run'. This one is older syntax and will be removed on a later period. Try the simple syntax format writen in document" ,
191-                     2 ,
192-                 )
193-             splitted  =  str (action_value ).split ("," )
194-             for  each  in  splitted :
195-                 try :
196-                     string  =  str (each ).split ("#" )[1 ].strip ()
197-                     if  string .endswith (")" ):
198-                         string  =  string [:- 1 ]
199-                     elif  " "  in  string :
200-                         string  =  string .split (" " )[0 ]
201-                     data_set_nums .append (int (string ) -  1 )
202-                 except :
203-                     pass 
204-         elif  "if"  in  action_value .lower ():
186+ 
187+         if  step_loop  and  'nextactions'  in  action_value :
188+             CommonUtil .ExecLog ("get_data_set_nums" , "'next_actions' is not valid in step loop" , 3 )
189+             return  []
190+         if  not  step_loop  and  'nextsteps'  in  action_value :
191+             CommonUtil .ExecLog ("get_data_set_nums" , "'next_steps' is only valid in step looping" , 3 )
192+             return  []
193+ 
194+         action_value  =  action_value .replace ('nextactions' , str ([i  for  i  in  range (int (CommonUtil .current_action_no )+ 1 , len (CommonUtil .all_step_dataset [int (CommonUtil .current_step_no )- 1 ])+ 1 )])[1 :- 1 ])
195+         action_value  =  action_value .replace ('nextsteps' , str ([i  for  i  in  range (int (CommonUtil .current_step_no )+ 1 , len (CommonUtil .all_step_dataset ))])[1 :- 1 ])
196+         if  'next'  in  action_value :
197+             for  each  in  set (['next'  +  m  for  m  in  re .findall ('next([-+]\d+)?' , action_value )]):
198+                 if  each  ==  'next' :
199+                     continue 
200+                 if  step_loop :
201+                     action_value  =  action_value .replace (each , str (eval (each .replace ('next' , str (int (CommonUtil .current_step_no )+ 1 )))))
202+                 else :
203+                     action_value  =  action_value .replace (each , str (eval (each .replace ('next' , str (int (CommonUtil .current_action_no )+ 1 )))))
204+             if  step_loop :
205+                 action_value  =  action_value .replace ('next' , str (int (CommonUtil .current_step_no ) +  1 ))
206+             else :
207+                 action_value  =  action_value .replace ('next' , str (int (CommonUtil .current_action_no )+ 1 ))
208+         if  'this'  in  action_value :
209+             for  each  in  set (['this'  +  m  for  m  in  re .findall ('this([-+]\d+)?' , action_value )]):
210+                 if  each  ==  'this' :
211+                     continue 
212+                 if  step_loop :
213+                     action_value  =  action_value .replace (each , str (eval (each .replace ('this' , str (int (CommonUtil .current_step_no ))))))
214+                 else :
215+                     action_value  =  action_value .replace (each , str (eval (each .replace ('this' , str (int (CommonUtil .current_action_no ))))))
216+             if  step_loop :
217+                 action_value  =  action_value .replace ('this' , str (int (CommonUtil .current_step_no )))
218+             else :
219+                 action_value  =  action_value .replace ('this' , str (int (CommonUtil .current_action_no )))
220+ 
221+         action_value  =  action_value .replace ('to' , '' )
222+         if  "if"  in  action_value :
205223            valid , data  =  ('0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '-' , ',' ), "" 
206224            for  i  in  action_value :
207225                if  i  in  valid :
208226                    data  +=  i 
209227            data_set_nums  +=  get_data_set_nums (data )
210228
211229        else :
212-             splitted  =  str (action_value ).strip (). split ("," )
230+             splitted  =  str (action_value ).split ("," )
213231            for  each  in  splitted :
214232                try :
215233                    if  "-"  in  each :
@@ -530,7 +548,7 @@ def for_loop_action(step_data, data_set_no):
530548                CommonUtil .ExecLog (sModuleInfo , "This dataset of for loop action is deprecated. Download the latest dataset and use" , 2 )
531549                deprecation_log  =  False 
532550            if  row [1 ].strip ().lower () ==  "for loop action" :
533-                 values  =  get_data_set_nums (sr .get_previous_response_variables_in_strings (row [2 ].strip ()))
551+                 values  =  get_data_set_nums (sr .get_previous_response_variables_in_strings (row [2 ].strip ()),  step_loop )
534552                if  step_loop :
535553                    loop_steps  =  [list (range (len (CommonUtil .all_step_dataset [i ]))) if  i  in  values  else  [] for  i  in  list (range (len (CommonUtil .all_step_dataset )))]
536554                    CommonUtil .disabled_step  +=  [i + 1  for  i  in  values ]
@@ -582,6 +600,8 @@ def for_loop_action(step_data, data_set_no):
582600                    exit_loop_and_fail ["cond" ].append (row [2 ])
583601                elif  row [1 ].strip ().lower () ==  "optional loop settings" :
584602                    exit_loop_and_fail ["cond" ].append (sanitize_deprecated_dataset (row [2 ]))
603+                 else :
604+                     CommonUtil .ExecLog (sModuleInfo , "Wrong dataset provided for exit loop and fail" , 2 )
585605            elif  row [0 ].strip ().lower ().startswith ("exit loop" ): # exit loop or exit loop and continue 
586606                if  not  row [2 ].lower ().startswith ("if" ):
587607                    CommonUtil .ExecLog (sModuleInfo , "'if' keyword is not provided at beginning" , 3 )
@@ -606,6 +626,8 @@ def for_loop_action(step_data, data_set_no):
606626                    exit_loop_and_cont ["cond" ].append (row [2 ])
607627                elif  row [1 ].strip ().lower () ==  "optional loop settings" :
608628                    exit_loop_and_cont ["cond" ].append (sanitize_deprecated_dataset (row [2 ]))
629+                 else :
630+                     CommonUtil .ExecLog (sModuleInfo , "Wrong dataset provided for exit loop and continue" , 2 )
609631            elif  row [0 ].strip ().lower ().startswith ("continue to next iter" ):
610632                if  not  row [2 ].lower ().startswith ("if" ):
611633                    CommonUtil .ExecLog (sModuleInfo , "'if' keyword is not provided at beginning" , 3 )
@@ -630,6 +652,8 @@ def for_loop_action(step_data, data_set_no):
630652                    continue_next_iter ["cond" ].append (row [2 ])
631653                elif  row [1 ].strip ().lower () ==  "optional loop settings" :
632654                    continue_next_iter ["cond" ].append (sanitize_deprecated_dataset (row [2 ]))
655+                 else :
656+                     CommonUtil .ExecLog (sModuleInfo , "Wrong dataset provided for continue to next iter" , 2 )
633657
634658        if  all ([len (i ) ==  0  for  i  in  loop_steps ]):
635659            CommonUtil .ExecLog (sModuleInfo , "Loop action step data is invalid, please see action doc for more info" , 3 )
@@ -651,9 +675,6 @@ def for_loop_action(step_data, data_set_no):
651675                sr .Set_Shared_Variables (CommonUtil .dont_prettify_on_server [0 ], step_data , protected = True , pretty = False )
652676                sr .test_action_info  =  CommonUtil .all_action_info [step_cnt ]
653677                loop_this_data_sets  =  loop_steps [step_cnt ]
654-                 if  step_index  ==  CommonUtil .step_index  and  step_loop :
655-                     tmp_step_exit_fail_called  =  step_exit_fail_called 
656-                     tmp_step_exit_pass_called  =  step_exit_pass_called 
657678                for  data_set_index  in  each_step :
658679                    if  data_set_index  in  inner_skip :
659680                        continue 
@@ -682,6 +703,8 @@ def for_loop_action(step_data, data_set_no):
682703                    outer_skip  =  list (set (outer_skip  +  inner_skip ))
683704
684705                    if  result  ==  "passed"  and  data_set_index  in  exit_loop_and_cont ["pass" ][step_cnt ]:
706+                         step_exit_fail_called  =  False 
707+                         step_exit_pass_called  =  False 
685708                        CommonUtil .ExecLog (
686709                            sModuleInfo ,
687710                            "Loop exit condition satisfied. Action %s passed. Exiting loop"  %  str (data_set_index  +  1 ),
@@ -696,6 +719,8 @@ def for_loop_action(step_data, data_set_no):
696719                        die  =  True 
697720                        break 
698721                    elif  result  ==  "zeuz_failed"  and  data_set_index  in  exit_loop_and_cont ["fail" ][step_cnt ]:
722+                         step_exit_fail_called  =  False 
723+                         step_exit_pass_called  =  False 
699724                        CommonUtil .ExecLog (
700725                            sModuleInfo ,
701726                            "Loop exit condition satisfied. Action %s failed. Exiting loop"  %  str (data_set_index  +  1 ),
@@ -710,10 +735,14 @@ def for_loop_action(step_data, data_set_no):
710735                        die  =  True 
711736                        break 
712737                    elif  result  ==  "passed"  and  data_set_index  in  continue_next_iter ["pass" ][step_cnt ]:
738+                         step_exit_fail_called  =  False 
739+                         step_exit_pass_called  =  False 
713740                        CommonUtil .ExecLog (sModuleInfo , "Action %s passed. Continuing to next iteration."  %  str (data_set_index  +  1 ), 1 )
714741                        cont_break  =  True 
715742                        break 
716743                    elif  result  ==  "zeuz_failed"  and  data_set_index  in  continue_next_iter ["fail" ][step_cnt ]:
744+                         step_exit_fail_called  =  False 
745+                         step_exit_pass_called  =  False 
717746                        CommonUtil .ExecLog (sModuleInfo , "Action %s failed. Continuing to next iteration."  %  str (data_set_index  +  1 ), 1 )
718747                        cont_break  =  True 
719748                        break 
@@ -749,10 +778,6 @@ def for_loop_action(step_data, data_set_no):
749778                        die  =  True 
750779                        break 
751780
752-                 if  step_index  ==  CommonUtil .step_index  and  step_loop :
753-                     # If this for loop is the one who initiated the step loop then recall its original step_exit values 
754-                     step_exit_fail_called  =  tmp_step_exit_fail_called 
755-                     step_exit_pass_called  =  tmp_step_exit_pass_called 
756781                if  die  or  cont_break :
757782                    break 
758783            if  die :
@@ -2382,4 +2407,6 @@ def Action_Handler(_data_set, action_row, _bypass_bug=True):
23822407if  4  ,9 ,10, 120-20 passes 
23832408if any passes 
23842409if any any passes 
2385- if ay passes''' 
2410+ if ay passes 
2411+ this-1199athis+-1,this+1 
2412+ ''' 
0 commit comments