Failed to locate opened application
Hello, I am using WinAppDriver to launch a windows Desktop application that is made using WPF. Using simple java code. When I run the script at first time, app launches and displays splash screen but it fails to execute further operation what I expect. It always showing error in the console "Failed to locate opened application window with appId:" I don't close current splash screen and run the same script second time, it opens another splash screen and executes entire script successfully.
I really wonder why it is unsuccessful at first run and successful at second run. It seems to be simple fix but I couldn't figure it out what I am missing. Please help me to get a solution for this. Here is my script.
package com.tests;
import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.windows.WindowsDriver; import io.appium.java_client.windows.WindowsElement;
public class Dummy { static WindowsDriver driver;
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.setCapability("app", "C:\\Program Files\\VI Enterprise\\VI MonitorPlus\\VIMonitorPlus.exe");
driver = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4723"), appCapabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElementByName("VI MonitorPlus").click();
driver.findElementByAccessibilityId("txtUserName").click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElementByAccessibilityId("txtUserName").clear();
}
}

Your help is greatly appreciated.
Read FAQ
I tried some techniques form FAQ but couldn't succeed. I am very new to use this WinAppDriver. I need some in person(Via zoom) help to make it work. Someone please help.
Yes you can ping me at [email protected]
I believe the issue is because of the splash screen that is getting displayed before the application window.
-
You can try disabling the splash screen using appArguments. e.g: appCapabilities.AddAdditionalCapability("appArguments", "-nosplash");
-
You can also try applying the delay to get to the application window handle using the below setting. I know how to do it in C#, you can use the equivalent in Java. I guess it could be the same for Java as well. e.g: appCapabilities.AddAdditionalCapability("ms:waitForAppLaunch", "25");
Please let me know if it resolves your issue.
Hi there, I am experiencing the same issue. I am using Javescript. I am using a .bat file to launch my app. Because the nature of the app is to get added to the system tray when the .exe gets executed. I couldn't find a way to double click the app icon from the system tray. Hence using a .bat file.
Any help is much appreciated.
Error : Failed to locate opened application window with appId:
My code,
import { driver, windowsAppDriverCapabilities } from 'selenium-appium'
const appId = 'D:\Users\kasun\Downloads\quality.bat'
class TestEnvironment { setup() { jest.setTimeout(60000); const capabilities = windowsAppDriverCapabilities(appId); return driver.startWithCapabilities(capabilities); } teardown() { return driver.quit(); } }
export default new TestEnvironment();