jeudi 13 août 2020

Element not found. How to test sequence of steps in multi-page WPF app with winappdriver?

I have a WPF application that features several pages. Navigation takes place after selecting some of the buttons. I am able to start the testing session successfully and to find elements in the main window. However, when clicking the "OK" button that should trigger navigation to another page, the app does not navigate and the test case fails to find UI elements in the next page. I have tried ImplicitWait and Thread.Sleep but the elements still cannot be found. It seems like the app does not navigate at all when the button is clicked.

Any ideas on how to tackle this issue? Below is what I have accomplished so far:

namespace TestDAAC
{
     [TestClass]
     public class UnitTests
    {
        protected const string WINAPPDRIVER_URL = "http://127.0.0.1:4723";
        private const string DAAC_APP_ID = @"C:\Users\Admin\Desktop\VC PROJECTS\daac\DAAC\bin\x64\Release\DAAC5.exe";

        protected static WindowsDriver<WindowsElement> daacSession;

        [ClassInitialize]
        public static void Setup(TestContext context)
        {
            if (daacSession == null)
            {
                var appiumOptions = new AppiumOptions();
                appiumOptions.AddAdditionalCapability("app", DAAC_APP_ID);
                appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
                daacSession = new WindowsDriver<WindowsElement>(new Uri(WINAPPDRIVER_URL), appiumOptions);
            }
        }

        [TestMethod]
        public void SequenceOfSteps()
        {
            daacSession.FindElementByName("OK").Click();
            Thread.Sleep(5000);
            // daacSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            daacSession.FindElementByName("New Imaging Session").Click();
        }
    }
}


    

Aucun commentaire:

Enregistrer un commentaire