Jul
16
2010

File dialog automation using White framework

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.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent is awarded by Microsoft since Avril 2002: Most Valuable Professional (MVP).

MVP
Certified ScrumMaster
JetBrains Academy Member

My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List