Using TestStack.White to test a controls which fire off background work

341 Views Asked by At

I am trying to write UI test case for a WPF application. This consists of a search textbox. On providing input into the textbox, search for the input string is done in a background thread.

This is my basic code:

public void TestMethod1()
{
    var applicationDirectory = @"C:\projects\dev\source\bin\Debug";
    var applicationPath = Path.Combine(applicationDirectory, "Some.exe");

    Application application = Application.Launch(applicationPath);
    Window mainWindow  = application.GetWindow("Window Title");

    mainWindow.Get<TextBox>().Text = "testing things out";

    Assert.IsTrue(true);

    mainWindow.Dispose();
    application.Dispose();
}

Now on the line where I set Text property, the background work will start, and the framework throws the exception:

TestStack.White.UIItems.UIActionException : Window didn't respond, after waiting for 50000 ms

Basically the framework waits for a configured amount of time and then throws the exception as the background work did not finish in time.

I have checked the documentation and it mentions a workaround, but that would involve me changing my application code. Since this is a legacy application I do not want to change the code (we are in middle of migration, so want to keep code changes limited).

This seems to be a common issue, but have not been able to see any solution? Any ideas?

UPDATE The following code does work, though still not close to finding the solution to original issue.

mainWindow.Get<TextBox>().BulkText = "testing things out";
0

There are 0 best solutions below