skip to Main Content

I am a newbie to running automation on Desktop applications.
I am using:

  • Visual Studio Community 2022 (C#)
  • WinAppDriver 1.2.99 (tried also v1.2.1 and v1.1.1)
  • .Net 4.8
  • Selenium.WebDriver 3.141.0 and Selenium.Support 3.141.0 (downgraded from 4.14.1)

As the first step I am trying to get all already-running windows and then connect to a specific running application.
I went over almost all online posts, and while using the code below I constantly receive a timeout exception.

Code:

[TestClass]
public class UnitTest1
{

    private const string WindowsDriverUri = "http://127.0.0.1:4723";

    [TestMethod]
    public void TestMethod1()
    {
        AppiumOptions desktopCapabilities = new AppiumOptions();
        desktopCapabilities.AddAdditionalCapability("app", "Root");
        desktopCapabilities.AddAdditionalCapability("platformName", "Windows");
        desktopCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
        Console.WriteLine(desktopCapabilities);
        using (WindowsDriver<WindowsElement> desktopSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desktopCapabilities))
        {
            var windows = desktopSession.FindElementsByClassName("Window");
            Console.WriteLine(windows);
        }
    }
}

Exception while calling FindElementsByClassName("Window"):

Message: 
Test method UnitTestProject1.UnitTest1.TestMethod1 threw exception: 
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/session/D45E9F54-E27A-4195-AB54-19C9DD040D69/elements timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.

  Stack Trace: 
HttpWebRequest.GetResponse()
HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
HttpCommandExecutor.Execute(Command commandToExecute)
AppiumCommandExecutor.Execute(Command commandToExecute)
RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
RemoteWebDriver.FindElements(String mechanism, String value)
AppiumDriver`1.FindElementsByClassName(String className)
UnitTest1.TestMethod1() line 29

Any idea how to resolve this?

Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    Thank you, already converted my code to the above sample and still same issue occurs. Tried also to work with Appium server instead of WinAppDriver.exe but now have some unresolved exception:

    Test method UnitTestProject1.UnitTest1.TestMethod1 threw exception: 
    OpenQA.Selenium.WebDriverException: An unknown server-side error occurred 
    while processing the command. Original 
    error: WinAppDriver server is not listening within 10000ms timeout. Make 
    sure it could be started manually
    
    Stack Trace: 
    RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
    RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 
    parameters)
    RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
    RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities 
    desiredCapabilities)
    AppiumDriver`1.ctor(Uri remoteAddress, ICapabilities appiumOptions)
    UnitTest1.CreateSessionForAlreadyRunningApp(String appText) line 52
    UnitTest1.TestMethod1() line 70
    

  2. Search elements using such a common locator under all Desktop elements is not a good idea because it can be a lot of elements on the desktop. I suppose WinAppDriver can be not so performance proficient.

    Try:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search