Test Automation‎ > ‎

WPF manipulation

The following samples are [ from / here ] downloadable. 

When operating a WinForm application, of course, a Friendly basic function is also used, 
but if the following libraries are used, it can be operated still more easily. 

This sample is the code which operates the following application using them. 
If the Add button is pushed, a corporate information input screen is modal, it is displayed, and the input data is stored in ListBox of MainForm. 
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Codeer.Friendly;
using Codeer.Friendly.Dynamic;
using Codeer.Friendly.Windows;
using System.Diagnostics;
using WpfTarget;
using System.Windows;
using Codeer.Friendly.Windows.Grasp;
using RM.Friendly.WPFStandardControls;

namespace WpfSample
public class UnitTest
WindowsAppFriend _app;

public void TestInitialize()
            _app =
new WindowsAppFriend(Process.Start("WpfTarget.exe"));

public void TestCleanup()

public void Test()

dynamic mainCore = _app.Type<Application>().Current.MainWindow;
var main = new WindowControl(mainCore);

var _buttonAdd = new WPFButtonBase(mainCore._buttonAdd);
var _listBoxData = new WPFListBox(mainCore._listBoxData);

var async = new Async();

var input = main.WaitForNextModal();
dynamic inputCore = input.Dynamic();

var _grid = new WPFDataGrid(inputCore._grid);
var _buttonOK = new WPFButtonBase(inputCore._buttonOK);
var _dateTimePickerFounding = new WPFDatePicker(inputCore._dateTimePickerFounding);
var _textBoxCompanyName = new WPFTextBox(inputCore._textBoxCompanyName);

new DateTime(2011, 3, 14));
            _grid.EmulateChangeCellText(0, 0,
            _grid.EmulateChangeCellComboSelect(0, 1, 2);
            _grid.EmulateChangeCellText(1, 0,
            _grid.EmulateChangeCellComboSelect(1, 1, 1);


var data = (Company)_listBoxData.Dynamic().Items[0];

Assert.AreEqual("Codeer", data.Name);
Assert.AreEqual(new DateTime(2011, 3, 14), data.FoundingDate);
Assert.AreEqual(2, data.Members.Count);
Assert.AreEqual("ishikawa", data.Members[0].Name);
Assert.AreEqual(Language.CS, data.Members[0].Language);
Assert.AreEqual("yamada", data.Members[1].Name);
Assert.AreEqual(Language.CPP, data.Members[1].Language);

As remarks, If you make WinForms app, but a native window may be displayed. 
That is MessageBox, FileDialog, FolderDialog.