.Net app automation in leanft in C sharp

Below example illustrates how to automate .Net WinForms and WPF applications using LeanFT. Note that for automating the WinForms applications, you will have to use below namespace.
 
using HP.LFT.SDK.WinForms;

Note that for automating the WPF applications, you will have to use below namespace.
 
using HP.LFT.SDK.WPF;

Also ensure that you have loaded the add-ins for WinForms and WPF. Below example illustrates how to automate WPF application.
 
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK;
using System.Diagnostics;
using HP.LFT.SDK.WPF;
using System.Threading;

namespace LeanFtTestProject1
{
    [TestClass]
    public class WinFormsAndWpf : UnitTestClassBase<NotepadTest>
    {
        [ClassInitialize]
        public static void ClassInitialize(TestContext context)
        {
            GlobalSetup(context);
        }

        [TestInitialize]
        public void TestInitialize()
        {

        }

        [TestMethod]
        public void TestMethod1()
        {
            Process appProcess = new Process
            {
                StartInfo = { FileName = @"C:UsersSagarDownloadsBusAppGUI.exe" }
            };
            appProcess.Start();

            // wait for app to open
            Thread.Sleep(3000);

            
            IWindow wpfWindow = Desktop.Describe<IWindow>(new WindowDescription
            {
                WindowTitleRegExp = @"Bus Application"
            });

            var custEditBox = wpfWindow.Describe<IEditField>(new EditFieldDescription
            {
                ObjectName = @"customerName"
            });

            // enter the name of customer
            custEditBox.SetText("Paul");

        }

        [TestCleanup]
        public void TestCleanup()
        {
        }

        [ClassCleanup]
        public static void ClassCleanup()
        {
            GlobalTearDown();
        }
    }
} 

Complex problems, Simple Solutions