Forum Discussion

nedbacan's avatar
nedbacan
Frequent Contributor
4 years ago
Solved

Measure the time it takes for a button to become enabled

Can someone instruct me how I would measure the time it takes for a button to become enabled on the screen.  Should I use aqPerformance.Start()  or will it be better to use aqDateTime.Now() as a stopwatch when the option is selected and then get the time again once the button is enabled.  

 

If you can provide a sample it would be helpful to understand,  I read the usage of the methods but not too clear where I can place it in a script.  There are areas where I place the wait/pause method to slow down the script but will that affect the time the button from disable to enable state, and how will I present the time in the log file. 

 

Use Case scanario

1) User select an image

2) Right-click on the image - a menu appears

3) Select the option to enable "MA" - a dialog appears showing a disabled button.

4) User waits (approx 30 seconds) until the button becomes enabled.  - the current dialog shows the button enabled.

5) If the button takes longer than 30 seconds - the test case fails because it took longer than the requirement.

 

//Right Click on image
Aliases.browser.pageImagenet.vgSvgslice0.ClickR(347, 138);
//Click the option to turn on the button
Aliases.browser.pageImagenet.textnodeProcessingmovingaverage.Click(25, 13);
//Runs a script routine to pause until the button is enabled.
WaitForButton();
//Checks whether the 'contentText' property of the NameMapping.Sys.browser.pageExam.panelResult.panel object equals 'ON'
aqObject.CheckProperty(NameMapping.Sys.browser.pageExam.panelResult.panel, "contentText", cmpEqual, "MA\nClose\nON\n0");
//Run the next keyword test.

 

Thank you for your support.

  • BenoitB's avatar
    BenoitB
    4 years ago
    yes, i just forgot the () ..
  • yes, i just forgot the () ..

    Parenthesis are required for JavaScript only and until now JavaScript was not mentioned in any way... 😉

     

  • nedbacan's avatar
    nedbacan
    4 years ago

    Problem solved with aqPerformance.Value().

     

    AlexKaras and BenoitBMy thanks to both of you and appreciation for your time.

13 Replies

  • BenoitB's avatar
    BenoitB
    Community Hero

    To wait for a property you can use .. WaitProperty 😁

     

    To measure time, several methods exists, choose one.

    aqPerformance is a good one.

     

    So you can use this :

     

      aqPerformance.Start("DefaultCounter", false);
      if (!yourButtonObject.WaitProperty("Enabled", true, 30000))
        throw Error("TC Failed : Enabled button state not occured within 30s !");
      Log.Message("TC Success : Enabled button state occured in " + aqPerformance.Value + "ms");
    
    
    

     

    • nedbacan's avatar
      nedbacan
      Frequent Contributor

      Hello BenoitB ,  I must be doing something wrong, can you check my code?

       

      I placed your example in my script, which will be called by the main keyword, the script will be called when the option to show the button is clicked, once is clicked the following function is run, but it keeps choosing "throw error", I am sure it has not been 30 seconds, in other words, it fails right away.

       

      function WaitForButton()
      {

      var button = Aliases.browser.pageExam.buttonOn

      aqPerformance.Start("DefaultCounter", false);

      if (button.WaitProperty("Enabled", true, 30000))

      throw Error("TC Failed : Enabled button state not occured within 30s !");

      Log.Message("TC Success : Enabled button state occured in " + aqPerformance.Value + "ms");

      }

       

      • BenoitB's avatar
        BenoitB
        Community Hero

        Does your button has the Enabled property ?

         

        The WaitProperty exit directly (what you have) when the property asked is missing :

        Result Value

        If the property achieves the specified value within the timeout, the method returns True. Otherwise, if the timeout elapses before the property achieves the specified value, the method returns False.

        Also, False if the object does not have the specified property.

         

         

        Put a breakpoint on line aqPerformance.Start("DefaultCounter", false); and when you come in, spy the button object.