Some GUI refresh are difficult to detect without doubt. The only clear difference is (in my case) the Handle.
Without completed GUI refresh, the following test step can fail. A workaround would be a huge timeout.
How to detect a changed Handle:
User-Code can be written firstly to save the actual Handle and secondly to wait until the saved Handle has changed. But this has to be done for every Repository-Item.
Is there an other way to detect a changed Handle?
A feature request would help: User-Code with Repository-Item as input parameter.
How to detect changed Handle
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to detect changed Handle
Hi,
Please explain your problem in detail, you want to detect if the GUI elements have changed or are updated?
Can you also send us two Ranorex snapshot files of your application, one before and one after the refresh?
Following link will show you how to generate a snapshot file.
Regards,
Markus
Ranorex Support Team
Please explain your problem in detail, you want to detect if the GUI elements have changed or are updated?
Can you also send us two Ranorex snapshot files of your application, one before and one after the refresh?
Following link will show you how to generate a snapshot file.
If you want to check if all/more elements have changed you have to test each of these, or did I miss something?How to detect a changed Handle ... but this has to be done for every Repository-Item.
Regards,
Markus
Ranorex Support Team
Re: How to detect changed Handle
With some help by the Support Team I implemented two Methods.
Check if Mouse.CursorName != "WaitCursor" during 3s
Method Timeout ~= 20s (waitCountMax = 200 * 0.1s)
Wait for changed AttributeValue
The first execution will wait waitCountMax, if repo.varFileName is not set to the valid value.
Check if Mouse.CursorName != "WaitCursor" during 3s
Method Timeout ~= 20s (waitCountMax = 200 * 0.1s)
Code: Select all
public static void Wait_NotBusy()
{
String CursorName;
Int32 waitCountMax = 200; // Method Timeout ~= 20s
Int32 notBusyCountMax = 30;
Int32 notBusyCount = 0;
Report.Info("Wait_NotBusy");
for (int waitCount = 1; waitCount <= waitCountMax; waitCount++)
{
Delay.Duration(100, false);
try
{
CursorName = Mouse.CursorName;
if (CursorName != "WaitCursor")
{
notBusyCount++;
} else {
notBusyCount = 0;
//Report.Warn("CursorName [" + CursorName + "] Reset notBusyCount" );
}
if (notBusyCount >= notBusyCountMax)
{
break;
}
}
catch (Exception e2)
{
Report.Debug("Exception occured: " + e2.ToString());
if (e2.GetType().ToString() != "System.NullReferenceException")
{
Report.Error("Unexpected exception occured: " + e2.ToString());
}
}
}
}
The first execution will wait waitCountMax, if repo.varFileName is not set to the valid value.
Code: Select all
public static void openedPDF()
{
Int32 waitCountMax = 6;
int waitCount;
//Report.Warn("openedPDF");
try
{
for (waitCount = 0; waitCount < waitCountMax; waitCount++)
{
//Report.Warn("opened PDF >>> repo.varFileName: " + repo.varFileName + " waitCount: "+ waitCount );
if (repo.ARTSViewer.DocViewer.AdobeReader.SelfInfo.Exists())
{
string fileNameTemp = repo.ARTSViewer.DocViewer.AdobeReader.PDF_Title_Hidden.Element.GetAttributeValue("Caption").ToString();
if (fileNameTemp != repo.varFileName)
{
Report.Info("opened PDF: " + fileNameTemp + "." );
repo.varFileName = fileNameTemp;
break;
}
Delay.Duration(500, false);
}
}
if (waitCount == waitCountMax)
{
Report.Info("No other PDF opened!" );
}
}
catch (Exception e2)
{
Report.Debug("Exception occured: " + e2.ToString());
if (e2.GetType().ToString() != "System.NullReferenceException")
{
Report.Error("Unexpected exception occured: " + e2.ToString());
}
}
}