Repository for Application with different windows

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
grid
Posts: 5
Joined: Mon Aug 16, 2010 12:25 pm
Location: Switzerland
Contact:

Repository for Application with different windows

Post by grid » Mon Aug 16, 2010 3:19 pm

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

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Repository for Application with different windows

Post by Ciege » Mon Aug 16, 2010 4:06 pm

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?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

grid
Posts: 5
Joined: Mon Aug 16, 2010 12:25 pm
Location: Switzerland
Contact:

Re: Repository for Application with different windows

Post by grid » Mon Aug 16, 2010 4:48 pm

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.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Repository for Application with different windows

Post by Ciege » Mon Aug 16, 2010 4:58 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Repository for Application with different windows

Post by artur_gadomski » Tue Aug 17, 2010 7:46 am

You could also tailor RxPath to select all windows of your application and then select the right one in code.

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

Re: Repository for Application with different windows

Post by Support Team » Tue Aug 17, 2010 12:51 pm

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
.
Image

grid
Posts: 5
Joined: Mon Aug 16, 2010 12:25 pm
Location: Switzerland
Contact:

Re: Repository for Application with different windows

Post by grid » Wed Aug 18, 2010 9:50 am

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.