Forum Discussion

Oussama's avatar
Oussama
Occasional Contributor
10 years ago

Getting Start and end Date of Running Project

Hello,

 

I would like to develop a scipt (JScript) which using the folowing variable:

-- Start date/Time of lunching project

-- End date/time 

-- Duration

How can i do this ?

 

Thank you.

  • This will allow for you to attain the duration in milliseconds:

    //record start time
    var start = new Date().getTime();
    
    /*
        run scripts
    */
    
    //record end time
    var end = new Date().getTime();

    //calculate the duration in milliseconds
    var duration = (end - start);

    //in seconds
    var durationseconds = duration / 1000;

    //so on and so forth

     

    You can use TestComplete's built in methods to attain the date and time:

    //Log the start time of the script
    Log.Message("Script was started at: " + aqDateTime.Now());
    
    /*
        run scripts
    */
    
    //Log the stop time of the script
    Log.Message("Script was stopped at: " + aqDateTime.Now());

3 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    This will allow for you to attain the duration in milliseconds:

    //record start time
    var start = new Date().getTime();
    
    /*
        run scripts
    */
    
    //record end time
    var end = new Date().getTime();

    //calculate the duration in milliseconds
    var duration = (end - start);

    //in seconds
    var durationseconds = duration / 1000;

    //so on and so forth

     

    You can use TestComplete's built in methods to attain the date and time:

    //Log the start time of the script
    Log.Message("Script was started at: " + aqDateTime.Now());
    
    /*
        run scripts
    */
    
    //Log the stop time of the script
    Log.Message("Script was stopped at: " + aqDateTime.Now());
    • Oussama's avatar
      Oussama
      Occasional Contributor

      Thank you for your answer,

       

      But i need the start and end time of the global project (with many scripts to execute) , not only for one executed script.

       

      Thank you.

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        Same idea if you're doing it for a project, just start it before all the scripts and end it after them.  Change the comments to whatever works for you.