Writing first test with LeanFT in C#.Net

Now we are going to write one test to verify the calculator functionality using LeanFT.

We want to do below things.

  1. Launch calculator application.
  2. Check the title of the calculator window.
  3. Click 8 button and Verify the result.
  4. Close the calculator.

Below program will perform all above operations. Please note that I have used Object Identification Center to get the description code for the calculator objects. Note that below code will work only on windows 7 calculator. The calculator app in windows 10 is designed using different technology.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK.Descriptions;
using HP.LFT.UnitTesting;
using HP.LFT.Common;
using HP.LFT.SDK.Web;
using HP.LFT.SDK;
using HP.LFT.Report;
using HP.LFT.SDK.StdWin;
using System.Diagnostics;

namespace leanFT
    public class UnitTest1

        public void TestCalculator()
            SDK.Init(new SdkConfiguration());
            Reporter.Init(new ReportConfiguration());
           IWindow win = Desktop.Describe<IWindow>(new WindowDescription
                IsOwnedWindow = false,
                IsChildWindow = false,
                WindowClassRegExp = @"CalcFrame",
                WindowTitleRegExp = @"Calculator"

           Trace.WriteLine("Calculator window title is " + win.WindowTitleRegExp);

           var button8 = win.Describe<HP.LFT.SDK.StdWin.IButton>(new HP.LFT.SDK.StdWin.ButtonDescription
               Text = string.Empty,
               WindowId = 138,
               NativeClass = @"Button"

          var result = win.Describe<IStatic>(new StaticDescription
               WindowId = 150,
               NativeClass = @"Static"
          Trace.WriteLine("Result text contains " + result.Text);



You may also like...