Assertions in leanft in C sharp

Assertions can be added in the LeanFT tests using Verify class as shown in below example. Note that Verify class has below methods.
  • AreEqual , AreNotEqual
  • IsTrue, IsFalse
  • StartsWith, Contains, EndsWith
  • LessOrEqual, Less, Greater, GreaterOrEqual
  • IsMatch
  • IsNullOrEmpty, IsNotNullOrEmpty
Below report shows that verification was successful.
 
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
{
    [TestClass]
    public class Assertions
    {
        [TestMethod]
        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";
            Reporter.Init(r);

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

            // Navigate to www.softpost.org
            browser.Navigate("https://www.softpost.org/selenium-test-page/");

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

            });

            firstName.SetValue("sagar");

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

            browser.Close();

            Reporter.GenerateReport();
            SDK.Cleanup();
        }
    }
}

Web development and Automation testing

solutions delivered!!