0

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";
peeyush singh
  • 1,337
  • 1
  • 12
  • 23
  • Have you tried your scenario with UIAutomationVerify/UISpy? Did it work? You can use `Retry.For` until your element appears – Pavel Anikhouski Mar 20 '19 at 08:48
  • Have checked it with UIAutomationVerify and it works. Have not tried `Retry.For` yet, will try to use that, my problem is that the textbox value is also not set, so essentially there is nothing to search, as soon as the line hits .Text, the error happens without setting the value – peeyush singh Mar 20 '19 at 08:51
  • Could be a threading issue since you writing to the GUI. – phatoni Mar 20 '19 at 11:11

0 Answers0