microsoft / WinAppDriver

Windows Application Driver
MIT License
3.66k stars 1.4k forks source link

{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: #1890

Closed skotian2 closed 1 year ago

skotian2 commented 1 year ago

Hi All - I am trying to launch a windows based application using WinAppDriver latest version. Application launches successfully but the test keeps on failing because of the following error: OpenQA.Selenium.WebDriverException: Failed to locate opened application window with appId: C:\XXX\XXX.exe, and processId: 18368

Any insight or help would be highly appreciated. I have tried following solutions:

  1. Options.AddAdditionalCapability("ms:waitForAppLaunch", "25");
  2. Adding Thread
  3. Invoking exe as a admin
Shakevg commented 1 year ago

skotian2 Do you have a splash screen in your app?

skotian2 commented 1 year ago

Nope - I do not have any splash screen. I am trying to launch Cisco Jabber messenger app if that helps.

Shakevg commented 1 year ago

Try this approach https://github.com/microsoft/WinAppDriver/issues/1323#issuecomment-1022542052

skotian2 commented 1 year ago

@Shakevg - I have tried the approach and still having the same error. I also tried with changing the path type by adding quotes no luck still. Please note that CiscoJabber opens up , but still test fails with the below error mentioned.

System.Diagnostics.Process.Start("C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); AppiumOptions Options = new AppiumOptions(); Options.AddAdditionalCapability("app", "C:\Program Files (x86)\Cisco Systems\Cisco Jabber\CiscoJabber.exe"); Options.AddAdditionalCapability("deviceName", "WindowsPC"); Options.AddAdditionalCapability("isHeadless", true); Options.SetLoggingPreference(OpenQA.Selenium.LogType.Server, OpenQA.Selenium.LogLevel.All); Options.AddAdditionalCapability("ms:waitForAppLaunch", "25"); CiscoJabberSession = new WindowsDriver(new Uri(DriverUrl), Options);

{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: C:\Program Files (x86)\Cisco Systems\Cisco Jabber\CiscoJabber.exe, and processId: 18020"}}

skotian2 commented 1 year ago

@Shakevg - This approach is working now Reference : Launching application using application parameters #1323

System.Diagnostics.Process.Start("C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe"); System.Diagnostics.Process.Start("C:\Cisco Systems\Cisco Jabber\CiscoJabber.exe"); Thread.Sleep(15000);

        // Create a session for Desktop
        AppiumOptions Options = new AppiumOptions();
        Options.AddAdditionalCapability("app", "Root");
        desktopSession = new WindowsDriver<WindowsElement>(new Uri(DriverUrl), Options);
        Assert.IsNotNull(desktopSession);

        //WindowsElement CortanaWindow = desktopSession.FindElementByName("Cisco Jabber");
        WindowsElement ACDLaunch = desktopSession.FindElementByName("Cisco Jabber");
Shakevg commented 1 year ago

skotian2 Instead of Thread.Sleep(15000); better to use wait

WebDriverWait wait = new WebDriverWait(desktopSession, TimeSpan.FromSeconds(15000));
wait.Until(ExpectedConditions.ElementExists(By.Name("Cisco Jabber")));
WindowsElement ACDLaunch = desktopSession.FindElementByName("Cisco Jabber");