0

I have an application that I would like to write an automated test for. The automated test will mimic an Operator's usage of the application. I cannot change the source code of the application as it is "frozen" for review.

The application will display a pop-up (message) window informing the operator to click on a button after measurements are finished. The button is enabled some time after the message window is closed.

I need to know how to detect when the application enables this button. My research so far indicates that the application should broadcast a custom message to help the automated testing; but I cannot modify the source code.

Also, the application will enable radio buttons after the "Measurements Finished" button has been clicked, asking if the measurements were valid. I need to detect this also.

Summary:

  1. How do I detect when a button (control) is enabled in another application?
  2. How do I get the handle of the other application?

I am using C# with MS Visual Express 2010 on Windows NT, Vista & 7. If you suggest tools, I need them to be free as the company has a very tight budget.

3
  • 1
    there are lots of tools. No matter what they cost, they will be cheaper than rolling your own. Commented Apr 21, 2011 at 17:18
  • @David except that they may view Thomas as a sunk cost Commented Apr 21, 2011 at 17:23
  • 2
    @David: Justifying the cost, submitting to the Powers and waiting for a response may take longer than writing an application. :-( Commented Apr 21, 2011 at 17:30

1 Answer 1

2

I think you could do the job using FindWindow API, passing title and receiving the handle.
Then, enumerating children components, you could find the button (if you catch its name, next time you can use it to be quicker) and get the enabled state.
I think you could use AutoIT software (script) or its logic.

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, int nptWindowName);

EDITED:
Check this link to find a simple way to do what you need.
I hope this helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

I'm dropping the writing of a test application in favor of using the AutoIT tool. So far, this is incredibly awesome and free! Thanks for the suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.