Firing events on web objects in LeanFT in C#.Net

Below example illustrates how to fire the event on web objects in C#.Net. In below example, we have fired click event on the web link.

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK.Web;

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

        [TestInitialize]
        public void TestInitialize()
        {

        }

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

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

            // Find Link Home
            ILink homeLink = browser.Describe<ILink>(new LinkDescription
            {
                InnerText = "Home",
                Index = 0        
                
            });

            homeLink.FireEvent(EventInfoFactory.CreateMouseEventInfo(MouseEventTypes.OnClick));
        
            browser.Sync();    

            browser.Close();
        }

        [TestCleanup]
        public void TestCleanup()
        {
        }

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

 

Note that we can fire various mouse events as shown in below image.

Firing Events on Web objects in LeanFT

Firing Events on Web objects in LeanFT

You may also like...