I'm sure many of you already noticed that the Ranorex 4 brought us new PopupWatcher functionality, to watch and handle unexpected dialogs. This means that we no loner need to implement separate dialog handling thread.
The PopupWather functionality not only allows to watch and handle the unexpected dialogs, but also to write information about them (screenshots, warnings) to the main test suite report. Something that was impossible with multi-threaded approach used in 3.x.
There is a quick example shown in the Ranorex user guide...
http://www.ranorex.com/support/user-gui ... html#c4678
And here comes my problem. I was able to implement the RxPath approach mentioned in the above sample. But I'm unable to make it working using repository elements. Or better said, I'm unable to make it working with other than info objects.
Here is my PopupWatcher implementation, which fails:
Code: Select all
class Program
{
public static xSpector.Repository repo = xSpector.Repository.Instance;
public static int TestFailVar = 0;
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
// Create PopupWatcher
PopupWatcher myPopupWatcher = new PopupWatcher();
myPopupWatcher.Watch(repo.Open.PathDoesNotExistStatic, ClosePopUpDialog);
// Start PopupWatcher
myPopupWatcher.Start();
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
return error;
}
public static void ClosePopUpDialog(Ranorex.Core.Repository.RepoItemInfo myRepoElement, Ranorex.Core.Element myElement)
{
Report.Screenshot(repo.Open.PathDoesNotExistStatic);
repo.Open.PathDoesNotExistBtnOK.Click();
}
}
Code: Select all
myPopupWatcher.Watch(repo.Open.PathDoesNotExistStatic, ClosePopUpDialog);
Here is how looks the repository... Thank you in advance for any suggestion.