PopupWatcher usage and reusability

Ask general questions here.
Samuel
Posts: 14
Joined: Tue Nov 12, 2013 10:50 am
Location: Germany (BW)

PopupWatcher usage and reusability

Post by Samuel » Thu Dec 05, 2013 5:07 pm

Ad described here it´s possible since Ranorex Version 4 to use the PopupWatcher Class for handling unexpected Popups.

However, the example only explains a few basics that might be enough for coders that are more skilled then I am. I couldn´t get it working right, so here are a few questions.

1) Once a instance of the watcher has been started how long is it running? If it runs indefinitaly it could be defined as separate UserCodeModule or Recorded Module. This would be great since I could then reuse it and wouldn´t have to specify it in every Module again, but do I then also have to call the Stop Method or are the watchers stopped by default once the Test-Case (or the whole Test-Run) finishes?

2) To test the PopupWatcher and code it in a reusable way I´ve added a UserCode Item to a Recording Module. It has 2 Variables to let the PopupWatcher know on which Popup it should react and which Button to press (therefore I´m passing in the Repository-Items-Names).

Unfortunately it doesn´t work because I can not find the Reository item by their names directly.
In the picture below you see the code.
I´m iterating through all repository items and want to find the one which has the same name like the one that I passed into the method.
The item in the example below is actually named "FehlerUngueltigerWert", however if I access the items name I get "Self".

Image

Maybe someone can enlighten me if there is a proper way to do this :D

Regards Samuel

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

Re: PopupWatcher usage and reusability

Post by Support Team » Tue Dec 10, 2013 5:49 pm

Hello Samuel,

Unfortunately, we would need more information about your issue.

Which Ranorex version do you use?
Could you please post or send us ([email protected]) your repository and a Ranorex Snapshot of your application? This would help us in analyzing your issue.

Thanks in advance.

Regards,
Markus (T)
.
Image

Samuel
Posts: 14
Joined: Tue Nov 12, 2013 10:50 am
Location: Germany (BW)

Re: PopupWatcher usage and reusability

Post by Samuel » Tue Dec 17, 2013 3:15 pm

Sorry for my slow reply. I kind of gave up on the popup watcher for now, because I encountered the additional problem, that even if I have a watcher that works while the Module is executed by its own, it fails once the module is used in a test case (even if the watcher is defined in the UserCode Init(){} section of a regular recorded Module and if the popup appears well before the execution of the module is finished).

Therefore I´ve written my own version of a popup blocker, which isn´t such a neat background process, but works for all Popups automatically. I did this by searching for and clicking on buttons that have the text OK or Close, but don´t have a AutomationID. Since all regular buttons of my app have a AutomationID this works like a charm.