Page 1 of 1

Repository for Application with different windows

Posted: Mon Aug 16, 2010 3:19 pm
by grid
Our application shows a window for each file that's opened, similar to Microsoft Word.
We are using a Ranorex repository and create tests against it by code.

Now, one test is to open two files which will show two windows. We could use the window title (which shows the filename of the opened file) to tell the windows apart. But how can I build a repository with the Ranorex Spy, which offers access to this window with a filename argument?

We are using Ranorex Professional, Version 2.3.3 on Windows7, forms are created using WPF.

Cheers & thanks,
Marcel

Re: Repository for Application with different windows

Posted: Mon Aug 16, 2010 4:06 pm
by Ciege
Can you explain what you mean a filename argument...

Is that filename in the window caption or visible in the window itself or even possibly a parameter in one of the windows objects?

Re: Repository for Application with different windows

Posted: Mon Aug 16, 2010 4:48 pm
by grid
I am thinking of the following scenario:

There is a manual written test that uses the repository to start the application and open two files (I've already done that). Now, two windows are showed, that differ in the filename displayed in the window title.

Here comes the tricky part: Now, I should check some states of controls on both windows. But the repository created with the Ranorex Spy only lets me create an access to a window of this type, or a window with exactly one title.

What I am looking for is a possibility to ask the repository for an open window of my application with the file xy opened, where the filename would be that mentioned argument.

I know, it is not that easy to describe... sorry for that.

Re: Repository for Application with different windows

Posted: Mon Aug 16, 2010 4:58 pm
by Ciege
So if the filename is displayed in the window title you should be able to use that as you unique window recognition.
Open RanorexSpy and check the properties of the window. There should be a ControlText or WindowText (or similar) property that has the actual text of the window title. If it does have the filename in it you can use that property as the differentiator between the two windows.

Something like:

Code: Select all

/form[@controlname='MyForm' and @windowtext='Microsoft Word - MyFilename']
Obviously the above is an example and would need to be tailored for your AUT.

Re: Repository for Application with different windows

Posted: Tue Aug 17, 2010 7:46 am
by artur_gadomski
You could also tailor RxPath to select all windows of your application and then select the right one in code.

Re: Repository for Application with different windows

Posted: Tue Aug 17, 2010 12:51 pm
by Support Team
Hi,

A possible solution would be to set the RxPath of the RepoItemInfo during runtime to a new RxPath. With following property http://www.ranorex.com/Documentation/Ra ... o_Path.htm of the repository item info object, you are able to get and set the RxPath of an item in the repository. To replace a specific string in the RxPath use the replace method from the String Class.
For example:
YourRepository repo = YourRepository.Instance;
//Get the RxPath of the element
string RxPath = repo.Application.FooInfo.Path.ToString();
//Repleace specific string of the RxPath and set the new
//RxPath to the element
repo.Application.FooInfo.Path = RxPath.Replace("foo","newfoo");
In this example the "foo" value is an attribute value of a container.

Regards,
Peter
Ranorex Team

Re: Repository for Application with different windows

Posted: Wed Aug 18, 2010 9:50 am
by grid
Hi Peter,

Thanks for your input.

Your suggestion was basically the solution that I was looking for. The replaced value ("newfoo") was the "argument" I was talking of, i.e. i was adding the the file name to the path string.

I still had some problems using it, because it was accessing the right window now, but its child objects were still pointing to the wrong window. The solution to this problem was to set the "UseCache" property of the whole application repository to false.

Now it's working perfectly.