Recommended way to identify windows dialogs

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:

Recommended way to identify windows dialogs

Post by grid » Mon Aug 16, 2010 2:51 pm

Hi everyone,

We are trying to build proper UI-Testrepositories for our application at the moment. Since the application supports multiple frontend languages, we do not want to match captions and window titles to identify objects in the repositories.

Has anyone found a good way to identify a Windows Dialog such as OpenFileDialog for building a repository without matching it via Caption? NativeWindow Class is always "#32770", no matter if it is an OpenFileDialog or a MessageBox.

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

Thanks for any suggestions,
Marcel

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

Re: Recommended way to identify windows dialogs

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

If you are trying to find a window that has no unique identifiers besides the index number and caption but want to be able to support multiple languages you will have to do some extra coding yourself.

Possibilities are:
1) Create a strings file that you reference with the different language conversions for each possible window.
2) Write some extra code that searches objects within a window to determine what type of window it is (such as does it have a file entry edit box or not, if so it's probably a OpenFileDialog window).
3) Use a RegEx expression to look for windows with captions like XXX or YYY.

You will have to get a little creative to work this problem since the uniqueness of the window is the caption and that is the one thing that changes with each different language. Fortunately with your own code you can have your developers crate specific object IDs, but when you start automating other peoples code (such as Windows dialogs) you are at the mercy of however they did it.
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: Recommended way to identify windows dialogs

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

Hi Ciege,

Thanks for the answer.
Ciege wrote: 2) Write some extra code that searches objects within a window to determine what type of window it is (such as does it have a file entry edit box or not, if so it's probably a OpenFileDialog window).
I feared, something like this would be suggested. So this would mean that I would search for this OpenFileDialog at test runtime rather than "save it" to the repository?

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

Re: Recommended way to identify windows dialogs

Post by Ciege » Mon Aug 16, 2010 5:03 pm

Well, I do not use the repository. All my automation searches are done at runtime. Not necessarily the best way to do it, but it is the way I do it... That being said, writing more code to make a better determination of what the window type is is not a bad thing to me...

However, if you want to stick with the repository and not have to write a lot more code you can try adding all the different instances of different languages to your repository item(s). That way a match would occur regardless of language tested against. This would require more upfront setup time on your part to determine the proper recognition strings and language differences for each unnamed form and those to your repository.
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...

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

Re: Recommended way to identify windows dialogs

Post by atom » Fri Aug 20, 2010 1:20 pm

Hiya

Class #32770 is the standard windows dialog class
See : http://msdn.microsoft.com/en-us/library ... 85%29.aspx

We have used that nice trick before to search for all top level windows with that class name to check for any dialogs...

Cheers