3

In a program that I'm testing with Coded UI Tests, I've got a window that opens for only a second or so, and I want to verify that this window is opening.

Is there a way to freeze the program, or make it run slow so that the test is able to find that window?

3
  • Why the window is closing after one second? Is it closing by your CodedUi Test (e.g. clicking 'close' button) or by the Application Under Test itself? Commented Jun 21, 2012 at 7:21
  • It's built into the application. It's basically a visible progress bar before another window opens with a generated document. Commented Jun 21, 2012 at 14:03
  • 2
    Then I'm afraid the only way to catch it is do this property configurable in your application's QA build. Some properties need to be configurable from QA team for testing purposes. Commented Jun 21, 2012 at 14:07

5 Answers 5

3

As I already mentioned in my comment there isn't much (perhaps nothing) you can do by the CodedUi Test to catch the window, since this functionality is built into the application.

My suggestion is to make this property configurable. Some of the properties in the applications under test need to be configurable so it can be tested. Consider the following requirements:

  • The service is restarting every month.
  • The user is deleted after one year of inactivity.

How would you test them? Will you wait a month or a year to go by? Those kind of parameters have to be available for the Qa team, otherwise they cannot be tested. I know that with this approach you have to do changes to your app's code and build but I think is the only way to solve it.

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

Comments

1

How about adding a Thread.Sleep(100);

http://msdn.microsoft.com/en-us/library/d00bd51t

Comments

0

From what I understand, the best approach is to break up your tasks as small as possible. So for a UI test I did that opens a shortcut on my toolbar, clicks login on a popup within, then clicks a tab in the application, the code looks like this:

namespace CodedUITestProject1 { /// <summary> /// Summary description for CodedUITest1 /// </summary> [CodedUITest] public class CodedUITest1 { public CodedUITest1() { } [TestMethod] public void CodedUITestMethod1() { // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items. // For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463 this.UIMap.OpenWindow(); this.UIMap.ClickLogin(); this.UIMap.ClickDevelopment(); } //snip } 

So then in the ClickDevelopment() method, I know that the program should be visible, so rather than just dive right into the method actions, I can throw a Thread.Sleep() to make it visible for a little while longer.

public void ClickDevelopment() { Thread.Sleep(10000); #region Variable Declarations WinClient uIDevelopmentClient = this.UIQualityTrack30Window.UIItemWindow.UIQualityTrack30Client.UIDevelopmentClient; #endregion // Click 'Development' client Mouse.Click(uIDevelopmentClient, new Point(39, 52)); } 

3 Comments

Thread.Sleep isn't quite doing it. The main application where the button was clicked seems to be frozen for 10 seconds, but the window I'm trying to capture still disappears too quickly.
Do you have the button click in its own recorded method?
Yes. I have each action in its own method, this would work if the control I'm trying to assert isn't another window.
0

Use Playback.Wait(2000) instead of Thread.Sleep(2000);

Comments

0

Best possible method is to add polling mechanism. As soon as you perform the action which will open the window, call a function which will keep checking whether the window appeared for say, 1 min or so.

Be sure to call this function as soon as you perform action. So even if the window stays for 500 millisecond, the info will be captured.

We have done similar thing in our project.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.