Automation of SAP Applications in LeanFT in C#.Net

We can automate the SAP applications using LeanFT with the help of SAP add-ins. You need to ensure 2 things before you start the automation of SAP applications.

  1. Load the SAP add-ins
  2. Ensure that you use the using HP.LFT.SDK.SAP namespace in your test
SAP Applications automation using LeanFT

SAP Applications automation using LeanFT

Below example illustrates how to automate SAP app.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK;
using System.Diagnostics;
using HP.LFT.SDK.SAP.UI5;
using HP.LFT.SDK.Web;
using System.Threading;

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

        [TestInitialize]
        public void TestInitialize()
        {

        }

        [TestMethod]
        public void TestMethod1()
        {
            IBrowser browser = BrowserFactory.Launch(BrowserType.InternetExplorer);

            // Open SAP application from test page
            browser.Navigate("https://sapui5.netweaver.ondemand.com/sdk/#test-resources/sap/ui/commons/ListBox.html");
            browser.Sync();
            Thread.Sleep(20000);

            // Find the Edit box.
            var editbox = browser.Describe<HP.LFT.SDK.SAP.UI5.IEditField>(new HP.LFT.SDK.SAP.UI5.EditFieldDescription
            {
                Id = @"txtFld"
            });

            // Enter the value in edit box
            editbox.SetValue("LeanFT");

        }

        [TestCleanup]
        public void TestCleanup()
        {
        }

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

You may also like...