views:

72

answers:

3

I'm working on some scripted GUI test for a windows C# .net app. I'm using Ruby to drive the testing and my feet are officially wet in the realms of WIN32API - but I'm certainly not over-confident with it. As a mater of fact, I feel like I'm missing some fundamental understanding. At this point, the only way I know how to gain access to different controls is through the combination of control class and maybe some identifying text.

My problem is, the application I have to test has a series of several buttons - all of which contain an icon and no text.

Is there a method I could use to retrieve a specific button? I've played with the notion of doing this via relative positioning, but that kind of sucks, and I'm not super interested in it.

I have access to the source code; if there is some identifying attribute/property that I can set, I'm more than willing. I'm just ignorant at this point.

Any advice appreciated -TIA!

A: 

Ok if there have icon then you can go on the page and view code. Then find out the button icon name in view code. You are get scr and alt parameter, then copy the name and past in following code.

ie.image(:src, /icon name/).click

or

ie.image(:alt, /icon name/).click

This is a think windows app, not rendered in a browser.
Bobby B
A: 

Unfortunately it's probably not easy. You'd want to enumerate all the windows and their children and look for "clues" as to which one is the button you want somehow, all using the win32api.

An example of "enumerating all windows" can be found in win32screenshot (search for "window_titles").

http://github.com/rdp/win32screenshot

-r

rogerdpack
Grrrr.... As you said not easy. There really isn't an answer to this problem. Enumerating all the children is the only feasible option I've found at this point, and the "clues" I've had to resort to are relative positioning.Using this as a windows testing framework is quickly becoming a non-option. Really a bummer, I was looking forward to this. Thanks for the attempt.
Bobby B
yeah. The latest version of win32screenshot gem has some "helpers" in the Win32::Screenshot::Util class, if that's any help.
rogerdpack
A: 

UI Automation like this is a PITA. I don't know Ruby so I can't help you with specifics but I can provide some thoughs from the last gui based harness I wrote. It was done in C# and I utilized the System.Runtime.InteropServices to access various functions in the user32.dll.

I was then able to build various methods that obtained the handle of the various GUI elements. Often it was a matter of getting the handle of the parent window and then the associated children until I got the correct control, used the handle then to perform what ever function was needed on that control. A tool like Spy++ or WinID is very useful for seeing what the relationships between the child and parent controls are as well as figure out if you are getting the correct handle as you are building out your harness.

Sorry I can't directly help you.

Dan Snell
You are correct about this being a PITA. I was already leveraging Spy++, but the best that gives you is a control handle. My problem is, I've got 7 buttons that are all children of the same parent (buttons all have the same control type). I've got to enumerate them. Thanks for the try.
Bobby B