WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Failed to locate opened application

Open Pushpa81 opened this issue 4 years ago • 5 comments

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();

}

}

image

Your help is greatly appreciated.

Pushpa81 avatar Jul 15 '21 22:07 Pushpa81

Read FAQ

anunay1 avatar Jul 16 '21 06:07 anunay1

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.

Pushpa81 avatar Jul 19 '21 15:07 Pushpa81

Yes you can ping me at [email protected]

anunay1 avatar Jul 20 '21 04:07 anunay1

I believe the issue is because of the splash screen that is getting displayed before the application window.

  1. You can try disabling the splash screen using appArguments. e.g: appCapabilities.AddAdditionalCapability("appArguments", "-nosplash");

  2. 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.

Umesh360480 avatar Aug 05 '21 07:08 Umesh360480

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();

khapuhetti avatar Jun 06 '22 22:06 khapuhetti