Synchronization in leanft in C sharp

We can add sync point in 2 ways.
  • WaitUntil method
  • Exists method
 
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK;
using HP.LFT.Verifications;
using System.Diagnostics;
using System.Threading;
using HP.LFT.SDK.StdWin;

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

        [TestInitialize]
        public void TestInitialize()
        {

        }

        [TestMethod]
        public void TestMethod1()
        {
            Process appProcess = new Process {
                StartInfo = { FileName = @"C:WindowsSystem32
otepad.exe" } };
            appProcess.Start();

            IWindow notepadWindow = Desktop.Describe<IWindow>(new WindowDescription
            {
                WindowClassRegExp = "Notepad",
                WindowTitleRegExp = " Notepad"
            });

            //wait until notepad is displayed
            bool isNotepadDisplayed = notepadWindow.WaitUntil((notepad) => { return notepad.IsVisible; });

            if (isNotepadDisplayed)
            {
                Console.WriteLine("Notepad Window Exists");
            }
            else
            {
                Console.WriteLine("Notepad Window does not Exist");
            }

            //Another way to add sync point in LeanFT
            if (notepadWindow.Exists(2))
            {
                Console.WriteLine("Notepad Window Exists");
            }
            else {
                Console.WriteLine("Notepad Window does not Exist");
            }
     
        }

        [TestCleanup]
        public void TestCleanup()
        {
        }

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

Web development and Automation testing

solutions delivered!!