0

我正在尝试使用Visual Studio Ultimate 2012 的编码 ui 测试为我的应用程序创建测试,在我的应用程序中我运行另一个应用程序(在“另一个应用程序”运行期间打开 cmd 窗口)。我想等到这个“另一个应用程序”完成运行,然后检查一些结果。我怎样才能做到这一点?

如果有人知道如何使用编码的 ui 测试控制窗口,我认为它可能会有所帮助,直到现在我还没有找到一个例子!

4

2 回答 2

0
  1. 就像@AdrianHHH 建议的那样尝试 UIMap.AnotherAppUIWindow.WaitForControlNotExist(); 只需使用适当的元素添加那行代码
  2. 在 try-catch 中抛出一个“while”,然后等待,捕获抛出的正确异常,例如找不到元素异常

    Try
    {
        while(UIMap.AnotherAppUIWindow.Exists)
        {
           //Do nothing
        }
    
    }catch(Exception)
    {
       //Window no longer exists
    }
    
于 2014-08-20T13:00:19.757 回答
0

我想办法。

我的问题是控制并等待与“另一个应用程序”执行相关的 cmd 窗口。

我运行系统和VS记录器,并在另一个应用程序的cmd窗口弹出时开始记录,然后我最大化窗口并停止记录,我这样做是为了获得自动生成的代码来控制这个窗口,我得到的代码:

    public void WaitUntilAnotherappFinish()
    {
        #region Variable Declarations
        WinWindow uIAnotherppWindow = this.UIAnotherappWindow
        #endregion

        // Maximize window 
        uIAnotherppWindow.Maximized = this.WaitUntilAnotherappFinishParams.UIAnotherappWindowMaximized;
    }

所以我将最大化窗口命令行替换为等待窗口不存在:

    public void WaitUntilAnotherappFinish()
    {
        #region Variable Declarations
        WinWindow uIAnotherppWindow = this.UIAnotherappWindow
        #endregion

        // wait for window to close 
        uIAnotherppWindow.WaitForControlNotExist();
    }

这正是我想要的:)。

重要提示:请注意此文件是自动生成的文件,因此您的更改可能会被撤消!通过在测试文件中实现自己的方法来解决这个问题。

于 2014-08-21T10:32:36.707 回答