Search code examples
c#winappdriver

WinAppDriver: Launching of desktop application was working fine, but of late its having issues


Launching of the desktop application was working fine when I automated using winAppDriver. Of late I observed these tests are failing.

Its failing at this line,

notepadsession = new WindowsDriver(new Uri("http://127.0.0.1:4723"), desiredcapabilities);

I tried both the codes, but still failing:

     var currentWindowHandle = notepadsession.CurrentWindowHandle;
        Thread.Sleep(TimeSpan.FromSeconds(5));
        var allWindowHandles = notepadsession.WindowHandles;
        notepadsession.SwitchTo().Window(allWindowHandles[0]);



    if (notepadsession.CurrentWindowHandle != notepadsession.WindowHandles.Last())
        {
            notepadsession.SwitchTo().Window(notepadsession.WindowHandles.Last());
        }

NOTE: It takes around 40-50 seconds to load the Desktop application.

Any help in this regard is highly appreciated.

Thanks


Solution

  • Below code solved the problem

    notepadsession = new WindowsDriver(new Uri("http://127.0.0.1:4723"), desiredcapabilities);
    
    Thread.Sleep(5000);    
    notepadsession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);