PopupWatcher.Watch: How to set testcase to FAIL?

Class library usage, coding and language questions.
bru
Posts: 18
Joined: Thu Oct 31, 2013 11:22 am
Location: Linz / Austria
Contact:

PopupWatcher.Watch: How to set testcase to FAIL?

Post by bru » Tue Mar 25, 2014 5:42 pm

As PopupWatcher.WatchAndClick reports the occurence of a popup just as Info, I tried to call my own method using PopupWatcher.Watch:

Code: Select all

 myCrashWatcher.Watch(repo.dlg_ToolCrash.btn_ProgrammSchliessenInfo, myCrashWatcherFunc);

public static void myCrashWatcherFunc(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)  
		{  
        	Report.Error ("myCrashWatcherFunc: program crashed!");
        	Report.Screenshot(myElement.Parent);
        	myElement.As<Ranorex.Button>().Click();
        }
This logs the popup as Error (Report Level = Error), but still the testcase in which this popup occured, will be reported as PASSED.

How can I set the testcase to FAIL?

Thanks,
Juergen

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by odklizec » Tue Mar 25, 2014 6:31 pm

Hi,

Try Report.Failure instead of Report.Error.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

bru
Posts: 18
Joined: Thu Oct 31, 2013 11:22 am
Location: Linz / Austria
Contact:

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by bru » Wed Mar 26, 2014 3:07 pm

Thanks a lot for your hint!

Best regards,
Juergen

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by odklizec » Wed Mar 26, 2014 3:12 pm

You are welcome!
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

bru
Posts: 18
Joined: Thu Oct 31, 2013 11:22 am
Location: Linz / Austria
Contact:

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by bru » Thu Mar 27, 2014 9:35 am

Sorry, I have to come back again.
(As this is a sporadic issue, I could not test it immediately)

It will be reported as failure (Level = Failure) now, but still the Recording and the Testcase in which this Popup occurs will be shown as Passed.

Does anybody have further ideas?

Thanks,
Juergen

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by odklizec » Thu Mar 27, 2014 10:45 am

Hi,

I think you are facing the same or similar problem as I did some time ago. The problem is that the popupwatcher runs in a separated thread. And as far as I know, there is currently no way to tell the main thread (from popupwacher thread) that the test case should be set as failed (eventually terminate the iteration/test case).

Please take a look at my post here:
http://www.ranorex.com/forum/command-to ... tml#p15846
Simply in the popup watcher, you need to set a variable, which needs to be evaluated somewhere in your test case/iteration (at start, at end, anywhere else?). Hope this helps? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

bru
Posts: 18
Joined: Thu Oct 31, 2013 11:22 am
Location: Linz / Austria
Contact:

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by bru » Mon Mar 31, 2014 4:54 pm

Thanks!

I've just tried your hint (static variable in class which will be set in popupwatcher method and will be evaluated at the end of the recording) and it works perfectly!

Thanks again!
Juergen

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: PopupWatcher.Watch: How to set testcase to FAIL?

Post by odklizec » Mon Mar 31, 2014 5:37 pm

You are welcome! I'm glad I could help.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration