Test Automation‎ > ‎

Winform 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 Codeer.Friendly.Windows.Grasp;
using System.Windows.Forms;
using Ong.Friendly.FormsStandardControls;
using FormTarget;

namespace FormSample
public class UnitTest
WindowsAppFriend _app;

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

public void TestCleanup()

public void Test()

dynamic mainFormCore = _app.Type<Application>().OpenForms[0];
var mainForm = new WindowControl(mainFormCore);

var _buttonAdd = new FormsButton(mainFormCore._buttonAdd);
var _listBoxData = new FormsListBox(mainFormCore._listBoxData);

var async = new Async();

var inputForm = mainForm.WaitForNextModal();
dynamic inputFormCore = inputForm.Dynamic();

var _dataGridView = new FormsDataGridView(inputFormCore._dataGridView);
var _buttonOK = new FormsButton(inputFormCore._buttonOK);
var _dateTimePickerFounding = new FormsDateTimePicker(inputFormCore._dateTimePickerFounding);
var _textBoxCompanyName = new FormsTextBox(inputFormCore._textBoxCompanyName);

new DateTime(2011, 3, 14));
            _dataGridView.EmulateChangeCellText(0, 0,
            _dataGridView.EmulateChangeCellComboSelect(1, 0, 2);
            _dataGridView.EmulateChangeCellText(0, 1,
            _dataGridView.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.