PopupWatcher in Ranorex 4 - problem with repo items

Class library usage, coding and language questions.
User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

PopupWatcher in Ranorex 4 - problem with repo items

Post by odklizec » Thu Feb 07, 2013 4:13 pm

Hi folks,

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();  
	}   
        
    }
The problem is in myPopupWatcher.Watch line, where the repo item used in first argument does not have SelfInfo attribute (because it's not a window but static text inside a dialog)...

Code: Select all

myPopupWatcher.Watch(repo.Open.PathDoesNotExistStatic, ClosePopUpDialog); 
So my question is, what attribute should I use instead of SelfInfo or how to modify the ClosePopUpDialog definition to accept the repo element without the RepoItemInfo attribute. I tried to remove RepoItemInfo attribute, but no luck here. I'm sure it's something simple I'm missing, because of my inexperience with C# coding ;)

Here is how looks the repository...
Repo.PNG
Thank you in advance for any suggestion.
You do not have the required permissions to view the files attached to this post.
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by Support Team » Fri Feb 08, 2013 5:11 pm

odklizec wrote:The problem is in myPopupWatcher.Watch line, where the repo item used in first argument does not have SelfInfo attribute (because it's not a window but static text inside a dialog)...
Are you sure? Every repository entry (root folder, app folder, and item) has a corresponding RepoItemInfo object. If you just pass in the "PathDoesNotExistStaticInfo" object to the myPopupWatcher.Watch method, your code should be fine.

Regards,
Alex
Ranorex Team

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

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by odklizec » Mon Feb 11, 2013 11:46 am

Hi Alex,

Thank you for the reply. You are of course right! I overlooked the "PathDoesNotExistStaticInfo" in the list of objects. From the example, I thought it must be used like "PathDoesNotExistStaticInfo.SelfInfo", but SelfInfo is not available for this particular static text and this has made me stuck ;)
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

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by Hermch » Tue Jun 11, 2013 2:44 pm

Hi,

I also have a problem with the PopupWatcher.

The code I wanted to try is like described in the example of Ranorex:

Code: Select all

      Public Shared Sub Watch_LogsTraces_LoadingData()
        	
        	_PopupWatcher.Watch(repo.Multistak.Popups.H1_LogsAndTracesInfo, NewDelay)
        	_PopupWatcher.Start
        	
        End Sub
        
        Public Shared Sub NewDelay(MyInfo As Ranorex.Core.Repository.RepoItemInfo,  MyElement As Ranorex.Core.Element)
        	
        	Report.Screenshot(repo.Multistak.Popups.H1_LogsAndTraces)
        	Delay.Seconds(1)
        	
        End Sub
On executing this code I get the following error messages:

Argument not specified for parameter 'MyInfo' of 'Public Shared Sub NewDelay(MyInfo As Ranorex.Core.Repository.RepoItemInfo, MyElement As Ranorex.Core.Element)'. (BC30455) - C:\Users\hermch\Documents\Ranorex\RanorexStudio Projects\Multistak\MultiLib\Popups\PopupChecker.vb:79,77

Argument not specified for parameter 'MyElement' of 'Public Shared Sub NewDelay(MyInfo As Ranorex.Core.Repository.RepoItemInfo, MyElement As Ranorex.Core.Element)'. (BC30455) - C:\Users\hermch\Documents\Ranorex\RanorexStudio Projects\Multistak\MultiLib\Popups\PopupChecker.vb:79,77

What am I doing wrong?

Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by Support Team » Wed Jun 12, 2013 3:42 pm

Hello,

I think the problem is that you forgot to add the "AddressOf" operator.
_PopupWatcher.Watch(repo.Multistak.Popups.H1_LogsAndTracesInfo, AddressOf NewDelay)
Please let me know if this solved the issue.
Thank you!

Regards,
Bernhard

Hermch
Posts: 40
Joined: Thu May 26, 2011 7:17 am
Location: Germany

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by Hermch » Thu Jun 13, 2013 3:05 pm

Hi,

unfortunatelly this does not solve the problem.

The errors which I got before are not reported now, but

Code: Select all

Public Shared Sub NewDelay 
is not executed anymore.
I've set a breakpoint to the Report.Screenshot line, but the breakboint never gets reached.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by Support Team » Fri Jun 14, 2013 3:31 pm

Hello,

Where do you call the Watch_LogsTraces_LoadingData() method?
Is this method reached?
The method NewDelay() will only be executed when the element "repo.Multistak.Popups.H1_LogsAndTraces" is available on your screen.
Please check if this is the case.

Regards,
Bernhard

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by atom » Tue Jul 02, 2013 1:35 pm

To me popup watchers are a working around an issue... If you get an unexpected dialog IMHO its better to let your test fail. If you close an unexpected dialog and attempt to continue with the test, your just masking a problem, and more often or not your test will fail for some other reason, making it harder to investigate!

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: PopupWatcher in Ranorex 4 - problem with repo items

Post by krstcs » Tue Jul 02, 2013 1:40 pm

atom, for most error conditions that would be true.

However, we have a conditional (cookie-based) pop-up on the website I am testing that comes up if you have never visited the site. Since I start most of my tests on clean browsers (no cookies to start), this always pops up, even though I may not actually care about it. I just cancel it and move on. If I need to test it, I will do it separately, due to what it is. In this situation, having the pop-up watcher helps make sure it is dealt with IF it pops up.
Shortcuts usually aren't...