Measure the time it takes for a button to become enabled
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Solved! Go to Solution.
- Labels:
-
Checkpoints
-
Keyword Tests
-
Test Results
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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");
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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");
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@BenoitB , I attached the Spy object and button to show you what I have. I am not sure what property I need. It first shows "OFF" and then I have to wait for it to turn to "ON".
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> var button = Aliases.browser.pageExam.buttonOn
Is it guaranteed that buttonOn exists at the moment when this line of code is executed?
If it is not guaranteed then try to replace the above line with
var button = Aliases.browser.pageExam.WaitAliasChild("buttonOn", 30000);
Does this help?
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Yes, the button is displayed on the screen. To test I manually called up the dialog with the button disabled,
I then execute the script and wait for the button to become enabled but the script fails right away (takes the throw error path). Tried WaitAliasChild and I get the same failure.
I added the script to the keyword test, when the option to open the dialog is called, the script is run so both (manually/automatically)
Can you review the Object spy copied within this trail of messages, I also added how the button looks?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
@nedbacan wrote:
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");
}
If you are talking about this code, then it works as expected:
-- The button becomes enabled within 30 seconds;
-- WaitProperty() returns 'true';
-- line with 'throw' statement is executed.
Code by Benoit was like this:
if (!button.WaitProperty("Enabled", true, 30000))
(note exclamation sign before 'button').
Does this help?
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please excuse me for the missed exclamation mark. I added the exclamation, and now it surpasses the throw error but the next statement issues "Cannot convert object to primitive value".
