0
votes

So I'm using CodedUI to do some application testing, and I've got the test framework built out for the most part and everything individually seems to be working.

My issue is that events are happening before the application is entirely loaded, so it's essentially just clicking on a blank page.

I've used Playback.Wait(x) and that doesn't seem to do the trick.

I have also attempted to use, but most likely incorrectly, the WaitForControlExist() also with no real luck.

Extremely new to CodedUI, especially with what i'm using this for. So any help would be greatly appreciated.

EDIT as per comments below:
Inside 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();
    }

Inside 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;
    }

Error: enter image description here

1
I've just posted a answer for this yesterday. See if that helps :) stackoverflow.com/a/41838745/5212566 - Prageeth Saravanan
@Prageeth I tried to implement it and it failed right at the call. I'm using an ApplicationUnderTest rather than a browser, how would I change this up to work for me? - d.rodriguez

1 Answers

0
votes

--ORIGINAL--

Load Wait Function:

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

and can call like:

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

I would invoke the method on a specific loading control, if the sync on the entire application does not yield expected result. You may also want to try methods like WaitForControlPropertyEqual

--Edit PER OP Request --

It is never a best practice to edit designer.cs file as the changes made to it will be lost. See here on why!

I would write a function on a separate .cs file. Some thing like,

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

then call that on my Coded UI Test method

    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);
    }