Throw Exception in PopupPathCallback

Ask general questions here.
Geci
Posts: 15
Joined: Fri Sep 06, 2013 1:16 pm

Throw Exception in PopupPathCallback

Post by Geci » Tue Sep 10, 2013 3:03 pm

Hello,
i have a new question :D. I use to identify MessageBoxes the PopupWatcher class:

Code: Select all

try
{
   ...
   PopupWatcher popupWatcher = new PopupWatcher() { EnableReportMessages = true };
   Action<RxPath, Element> callback = (path, element) =>
   {
	throw new TestException("Unknown messagebox", element);	
   };
   popupWatcher.Watch("/form[@class='#32770']", new PopupPathCallback(callback));
   popupWatcher.Start();
   ...
}
catch(TestException exc)
{
   Report.Snapshot(exc.Message, exc.Element);
   TestReport.EndTestModule(TestResult.Failed);
   TestReport.EndTestCase(TestResult.Failed);
}
But unfortunately I never get into the catch. The report is only
00:09.486 Error Popup Watcher Error in popup dialog handler.
Show/Hide Stacktrace
at Test.Program.<CreateModuleTest>b__1(RxPath path, Element element) in c:\Users\...\Documents\Visual Studio 2012\Projects\Test\Test\Program.cs:line 64 at Ranorex.PopupWatcher.FindPopups(PopupItemCallback itemCallback, PopupPathCallback pathCallback, RxPath absPath, String itemName, RepoItemInfo optionalInfo)

However, I would like to stop the test run in the callback method. What do I need for it?

And sorry for my "English" :D

Greetings
Geci

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Throw Exception in PopupPathCallback

Post by Support Team » Wed Sep 11, 2013 3:37 pm

Hello Geci,

The problem is that the popup watcher runs in an own thread. That means the exception will also be thrown in an own thread.
You can try to abort the main thread.
Unfortunately this is not a recommended by Ranorex and that's the reason that I cannot provide more detailed support, but maybe other users in the forum can give you more information.

Regards,
Bernhard
.
Image