等待应用程序使用CodedUI完全加载

时间:2017-01-26 16:13:24

标签: c# visual-studio automation coded-ui-tests

所以我正在使用CodedUI进行一些应用程序测试,并且我已经在大多数情况下构建了测试框架,并且所有内容似乎都在运行。

我的问题是在完全加载应用程序之前发生了事件,因此它实际上只是单击空白页面。

我已经使用了Playback.Wait(x),但这似乎没有成功。

我也试图使用WaitForControlExist(),但很可能是错误的,但没有真正的运气。

CodedUI非常新,特别是我正在使用它。所以任何帮助都将不胜感激。

根据以下评论编辑:
内部CodedUITest1.cs

    [TestMethod]
    public void CodedUITestMethod1()
    {
        this.UIMap.LaunchSoapUI();   //I WANT TO WAIT FOR THIS TO FULLY LOAD BEFORE GOING TO FindAndClickCustomFitNoRetest()
        this.UIMap.FindAndClickCustomFitNoRetest();
        this.UIMap.ClickPlayBtn();
        this.UIMap.EnterEmployeeID();
    }

在UIMap.Designer.cs内部

    public void LaunchSoapUI()
    {
        // Launch '%ProgramW6432%\SmartBear\SoapUI-5.3.0\bin\SoapUI-5.3.0.exe'
        ApplicationUnderTest soapUI530Application = ApplicationUnderTest.Launch(this.LaunchSoapUIParams.ExePath, this.LaunchSoapUIParams.AlternateExePath);
        WaitForAUTLoad(soapUI530Application, 120);
    }

    public void WaitForAUTLoad(ApplicationUnderTest aut, int WaitTimeOut)
    {
        Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
        aut.WaitForControlReady(WaitTimeOut * 1000);
        Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;
    }

错误: enter image description here

1 个答案:

答案 0 :(得分:0)

<强> - ORIGINAL -

加载等待功能:

public void WaitForAUTLoad(ApplicationUnderTest aut, int WaitTimeOut)
{
    Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
    aut.WaitForControlReady(WaitTimeOut * 1000);
    Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;
}

可以调用:

    ApplicationUnderTest soapUI530Application = ApplicationUnderTest.Launch(@"C:\Program Files\SmartBear\SoapUI-5.2.1\bin\SoapUI-5.2.1.exe");
    WaitForAUTLoad(soapUI530Application, 120);

如果整个应用程序上的同步没有产生预期结果,我会在特定的加载控件上调用该方法。您可能还想尝试WaitForControlPropertyEqual

等方法

- 编辑PER OP请求 -

  

编辑designer.cs文件作为更改绝不是最佳做法   制造它将失去。 See here on why!

我会在单独的.cs文件上编写一个函数。有点像,

public ApplicationUnderTest LaunchAUT(string exePath)
{
    return ApplicationUnderTest.Launch(exePath);
}

然后在我的Coded UI测试方法上调用它

    public void CodedUITestMethod1()
    {
        //Set path to SOAP UI Exe from your config 
        string SOAPUIExePath = @"C:\Program Files\SmartBear\SoapUI-5.2.1\bin\SoapUI-5.2.1.exe";
        ApplicationUnderTest SoapUI = LaunchAUT(SOAPUIExePath);            
        WaitForAUTLoad(SoapUI, 120);
    }
相关问题