First test in leanft in C sharp

Now we are going to write one test to verify the calculator functionality using LeanFT. We want to do below things.
  • Launch calculator application.
  • Check the title of the calculator window.
  • Click 8 button and Verify the result.
  • 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
{
    [TestClass]
    public class UnitTest1
    {

        [TestMethod]
        public void TestCalculator()
        {
            SDK.Init(new SdkConfiguration());
            Reporter.Init(new ReportConfiguration());
            Process.Start(@"d:WindowsSystem32calc.exe");
           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"
           });
           button8.Click();

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

        }

    }
}   

Web development and Automation testing

solutions delivered!!