Forum Discussion
AlexanderM
13 years agoStaff
Hello Anitha,
So, if I am getting it right, the number of pages that are already printed is constantly updating, and this indicates that the app is not hanging.
At that, when the number does not update during N seconds, you can tell that the app is hanging, and take the appropriate actions.
If this is the case, then it should be easy to detect this situation - just get the text at regular time intervals, and compare the current value with the last value. If the value is the same during more than N seconds, report an error, and stop the test. Below, is a sample script demonstrating this approach. You can combine the suggested approach with checking the dialog visibility to get exactly what you need.
Here is the sample:
function MakeSureTextConstantlyChanges()
{
// The maximum allowed time for the text to stay the same
var maxTimeWithNoTextChange_Seconds = 10;
// The final text value that means that the process is completed
var expectedFinalTextValue = "All pages printed";
var curValue;
// Get the initial values.
// getNumPagesText - is the function that is supposed to get the current text value
var lastValue = getNumPagesText();
var lastChangeTime = Win32API.GetTickCount();
// Start tracking the text to make sure it keeps changing
while(true)
{
Delay(1000, "Tracking the text value...");
// Get the current text
curValue = getNumPagesText();
curTimeStamp = Win32API.GetTickCount();
if (aqString.Compare(expectedFinalTextValue, curValue, true) == 0)
{
Log.Message("The text got the final value");
break;
}
// Check if the current text value is still the same
if (curValue == lastValue)
{
// If the value is the same, check how long the value is there
if (Win32API.GetTickCount() - lastChangeTime > maxTimeWithNoTextChange_Seconds * 1000)
{
Log.Error("The text is not changing for too long (" + maxTimeWithNoTextChange_Seconds + " seconds)");
Runner.Stop();
}
}
else
{
// If the text has changed, capture the new text and the time stamp
lastValue = curValue;
lastChangeTime = curTimeStamp;
}
}
}
function getNumPagesText()
{
... get the X value...
pagesprinted = X.HwndSource_Window.Window.PrintingJobDetailsUserControl.txtSheetsPrinted.get_Text;
return X;
}
I hope this helps!
Related Content
Recent Discussions
Check PopupMenu exists
Solved3 days agomfoster711- 4 days agosimonaferrara
- 5 days agomacheshmeh