Forum Discussion

leeasdf9's avatar
leeasdf9
Frequent Contributor
8 years ago

Solution wanted for time-tagged-data-driven-workflow

our testrequirement is to execute a data-driven-test, which should be able to execute a non-stop-test controled by time:

Requirement:

1st hour: execute only4 scenarios

2nd hour: execute only8 scenarios

3rd hour: execute only4 scenarios

 

Is there a simple way to fulfill this kind of requirement?

Thanks for any reply and support in advances,

Lee

 

 

 

DDT.ExcelDriver("C:\\MyFile.xls", "Sheet1");

while (! DDT.CurrentDriver.EOF())
  { 

    //Test steps...
    DDT.CurrentDriver.Next();
  }

4 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Let me understand your question,

     

    For ex: You have 15 different test steps that needs to be performed with time condition.

     

    1 Hr -  1 to 4

    2 Hr - 5 to 10

    3 Hr - 11 to 15

     

    Is this what you expecting to do?

    • leeasdf9's avatar
      leeasdf9
      Frequent Contributor

      exactly, thanks for your question.

      • shankar_r's avatar
        shankar_r
        Community Hero

        So, After a long confusion in my mind i found a way to do this logic. I tried with minutes it is working fine.

         

        If you want change the logic to Minutes or Seconds then Just change the Highlighted keyword to like GetMinutes or GetSeconds

         

        function ExecutionStepswithTimeCondition()
        {
              var timeConfiguration = Sys.OleObject("Scripting.Dictionary");
              var exestartTime = null,f_goandExecute = false,int_teststep_no = 0,currentHour = 1,previousHour = 0,no_ofSteps = 0;
              
              stopFile = "C:\\StopFile.txt"
              
              //Configure the number of test steps needs to be for the coressponding hour
              //timeConfiguration.Add("<nth Hour>",<Num of test steps>);             
              timeConfiguration.Add(1,4);
              timeConfiguration.Add(2,10);
              timeConfiguration.Add(3,15);
              timeConfiguration.Add(4,0);
              timeConfiguration.Add(5,12);
        
              DDT.ExcelDriver("D:\\Nectar_Automation\\01202017_Execution_Scripts\\Nectar_Automation_Project\\TestData.xls", "Master");
                    
              exestartTime = aqDateTime.Time();
                    
              while (! DDT.CurrentDriver.EOF())
              {
                    if(aqFile.Exists(stopFile))//To stop the execution when file present the specified location
                    {
                           if(aqDateTime.GetHours(aqDateTime.TimeInterval(exestartTime,aqDateTime.Time())) <= currentHour)
                           {
                                if(aqDateTime.GetHours(aqDateTime.TimeInterval(exestartTime,aqDateTime.Time())) >= previousHour)
                                {
                                      no_ofSteps = timeConfiguration.Item(currentHour);
                          
                                      if(int_teststep_no  <= no_ofSteps)
                                      {
                                            f_goandExecute = true; 
                                      }
                                }
                           }
                           else
                           {
                                int_teststep_no = 0;
                                previousHour = currentHour;
                                currentHour = currentHour + 1;
                                if(timeConfiguration.Item(currentHour) > 0)
                                {
                                      f_goandExecute = true;
                                }
                           }
                     
                          if(f_goandExecute)
                          {
                                //Test steps...Start
                                Log.Message(int_teststep_no + " - " + aqDateTime.Time());
                                //Test steps End
                                //********************************************************************
                                DDT.CurrentDriver.Next();
                                int_teststep_no = int_teststep_no + 1
                                f_goandExecute = false;
                          }
                    }
                    
                    
              }
        
        
        }

         

         

        If you like to stop the execution then you just need to place a file  in the specified path.(If you are giving shared drive path then you can stop the execution from any machine)