Assertions in LeanFT in C#.Net

Assertions can be added in the LeanFT tests using Verify class as shown in below example. Note that Verify class has below methods.

  1. AreEqual , AreNotEqual
  2. IsTrue, IsFalse
  3. StartsWith, Contains, EndsWith
  4. LessOrEqual, Less, Greater, GreaterOrEqual
  5. IsMatch
  6. IsNullOrEmpty, IsNotNullOrEmpty
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK;
using HP.LFT.Report;
using System.Diagnostics;
using System.Threading;
using HP.LFT.SDK.Web;
using System.Drawing;
using HP.LFT.Verifications;

namespace LeanFtTestProject1
    public class Assertions
        public void TestAssertions()

            SDK.Init(new SdkConfiguration
                ServerAddress = new Uri("ws://localhost:5095")

            ReportConfiguration r = new ReportConfiguration();
            r.IsOverrideExisting = true;
            r.Title= "My LeanFT Report";

            IBrowser browser = BrowserFactory.Launch(BrowserType.InternetExplorer);

            // Navigate to

            // Find edit box using Xpath
            IEditField firstName = browser.Describe<IEditField>(new EditFieldDescription
                XPath = "//input[@id='fn']"



            Verify.AreEqual("sagar", firstName.Value, 
                "Verifying the editbox value");



Below report shows that verification was successful.

LeanFT report assertions and verifications

LeanFT report assertions and verifications

You may also like...