Today TeamCity was showing me one functional test failure on my WPF application.

I already discussed about this problem here: White’s tip for your automated WPF functional tests

The solution I presented at that time was working on my local development environment but not on my Continuous Integration system; aka TeamCity. So I went for another solution which was searching for the filename ComboBox and was setting the value.

This was working for some time but today not anymore. The issue I discovered is that using the ComboBox needed that the path was already used in the past otherwise setting the value was failing. So I was stuck and had to find another solution.

I fired spy++ and searched for a solution and after some debugging I came to the following one:

var openModalWindow =
    MainWindow.ModalWindow("Please choose a Zip file", InitializeOption.NoCache);

MainWindow.WaitWhileBusy();
Assert.IsNotNull(openModalWindow);

var filePath = Path.Combine(GetCurrentPath(), filename);

var filenameTextBox =
    openModalWindow.Get<TextBox>(SearchCriteria.ByAutomationId("1148"));
filenameTextBox.SetValue(filePath);

openModalWindow.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN);

This is working on my local environment but also on TeamCity!

The key point was to find the TextBox with the AutomationId of 1148.