WinAppDriver
WinAppDriver copied to clipboard
Failed to locate opened application window with appId
I have an application i wish to open. This application has a splash screen that runs for approx 3-5 seconds. Then causes the process to temporarily stop responding and then continues to the login screen. This is all done on the same process Id and does not change.
This is the body of the request i am sending at start up
"{"desiredCapabilities":{"app":"{PATH TO EXE GOES HERE}","platformName":"windows","deviceName":"WindowsPC"},"capabilities":{"firstMatch":""},"session id":null}"
The issue is the app launches no problem, but the response from the request says that it fails to locate the application window.
I cannot put in a sleep because this is all happening on the request call through the HttpClient. My timeout is 60 seconds so i can't be that.
Thoughts?
Use the ms:waitForAppLaunch capability to delay the session from starting after app launch. This requires WinAppDriver 1.2. I also found it useful to explicitly set the ms:experimental-webdriver to false to fend off odd behavior.
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", AppPath);
options.AddAdditionalCapability("ms:waitForAppLaunch", $"{SecondsToWaitOnOpen}");
options.AddAdditionalCapability("ms:experimental-webdriver", false);
session = new WindowsDriver<WindowsElement>(WindowsApplicationDriverUrl, options);
I have the same issue.
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName", "WindowsPC");
// https://github.com/microsoft/WinAppDriver/issues/1092
desiredCapabilities.setCapability("ms:waitForAppLaunch", "8");
desiredCapabilities.setCapability("ms:experimental-webdriver", false);
WindowsDriver<WindowsElement> windowsDriver = new WindowsDriver<>(winappServerUrl, desiredCapabilities);
return windowsDriver;
The application (calc.exe) opens, but the WebDriver is not created.
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: Failed to locate opened application window with appId: C:\Windows\System32\calc.exe, and processId: 12772 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12.06 seconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
WinAppDriver (1.2.1) log:
==========================================
POST /session HTTP/1.1
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 493
Content-Type: application/json; charset=utf-8
Host: localhost:4723
User-Agent: selenium/3.141.59 (java windows)
{
"desiredCapabilities": {
"app": "C:\\Windows\\System32\\calc.exe",
"ms:waitForAppLaunch": "8",
"ms:experimental-webdriver": false,
"platformName": "Windows",
"deviceName": "WindowsPC"
},
"capabilities": {
"firstMatch": [
{
"appium:app": "C:\\Windows\\System32\\calc.exe",
"appium:deviceName": "WindowsPC",
"ms:experimental-webdriver": false,
"ms:waitForAppLaunch": "8",
"platformName": "windows"
}
]
}
}
HTTP/1.1 500 Internal Error
Content-Length: 168
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: C:\\Windows\\System32\\calc.exe, and processId: 12772"}}
It works when I use the application Microsoft.WindowsCalculator_8wekyb3d8bbwe!App
Setting the working dir as described here https://github.com/Microsoft/WinAppDriver/issues/516 and https://github.com/Microsoft/WinAppDriver/issues/360 did not work either:
==========================================
POST /session HTTP/1.1
Accept-Encoding: gzip
Connection: Keep-Alive
Content-Length: 589
Content-Type: application/json; charset=utf-8
Host: localhost:4723
User-Agent: selenium/3.141.59 (java windows)
{
"desiredCapabilities": {
"app": "C:\\Windows\\System32\\calc.exe",
"ms:waitForAppLaunch": "8",
"appWorkingDir": "C:\\Windows\\System32",
"ms:experimental-webdriver": false,
"platformName": "Windows",
"deviceName": "WindowsPC"
},
"capabilities": {
"firstMatch": [
{
"appium:app": "C:\\Windows\\System32\\calc.exe",
"appWorkingDir": "C:\\Windows\\System32",
"appium:deviceName": "WindowsPC",
"ms:experimental-webdriver": false,
"ms:waitForAppLaunch": "8",
"platformName": "windows"
}
]
}
}
HTTP/1.1 500 Internal Error
Content-Length: 168
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: C:\\Windows\\System32\\calc.exe, and processId: 15764"}}
We have tried to Automate Control Panel in windows using WinAppDriver and trying to go to View by Large Icon and click on System to get the Computer Name in it. We are running WinAppDriver on a 127.0.0.1 4723 and tried to automate using TestNG and Selenium. When we are automating applications like notepad.exe this is got successfully automated by using application path, but when we are trying to automate Control Panel, Command prompt, etc. with the application path from system32 of windows and even with AppID's also getting the issues (Errors are mentioned in the below sections).
Scenario 1: Tried with Application path as below:
DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability("app", "C:\WINDOWS\system32\control.exe"); cap.setCapability("Platform", "Windows 10"); cap.setCapability("Device Name", "Windows PC");
driver = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4723"), cap); Assert.assertNotNull(driver); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
Error: org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: Failed to locate opened application window with appId: C:\WINDOWS\system32\control.exe, and processId: 8768 (WARNING: The server did not provide any stacktrace information)
Scenario 2: Tried with AppID as below:
DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability("app", "Microsoft.Windows.ControlPanel"); cap.setCapability("Platform", "Windows 10"); cap.setCapability("Device Name", "Windows PC");
driver = new WindowsDriver<WindowsElement>(new URL("http:// ://127.0.0.1:4723"), cap); Assert.assertNotNull(driver); driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
Error:
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: The system cannot find the file specified (WARNING: The server did not provide any stacktrace information)
We are using WinAppDriver V1.2.1, OS Windows 10 pro and OS Build Version 19042.867
Since we are very new to WinAppDriver can anyone help us in resolving this issue
@KitoCoding Can you try cache for initial start app, then attach to it using process id or desktop session by window name in a loop until window will appear
@mreiche Are you still facing the issue or if it is resolved then let me know the resolution I am also facing the same issue?
@mreiche Are you still facing the issue or if it is resolved then let me know the resolution I am also facing the same issue?
Yes. But this doesn't affect my real world scenario. I was able to implement a working stable automation even without calc.exe
.
@mreiche How your desktop automation is working on the Remote machine?
@mreiche How your desktop automation is working on the Remote machine?
Well I'm actually not running tests against remote Windows. But when you have trouble to get your WindowsDriver to run with an application, try to find the running application by window title and initialize the driver using the window handle. That worked for me, is described here: https://github.com/Microsoft/WinAppDriver/blob/v1.0-RC2/README.md#attaching-to-an-existing-app-window and implemented here: https://github.com/telekom/testerra-appium-connector/blob/testerra2/appium/src/main/java/eu/tsystems/mms/tic/testframework/appium/WinAppDriverFactory.java#L104
@mreiche I have tried with the above solution but still it didn't help to resolve the issue on the remote machine.
@mreiche I have tried with the above solution but still it didn't help to resolve the issue on the remote machine.
Thats unfortunate.
I installed my test environment on a remote windows VM, which is working so far.
- I created a admin user with RDP access
- Enabled autologin for this user via https://docs.microsoft.com/en-us/sysinternals/downloads/autologon
- Enabled development mode
- Started
WinAppDriver
with public IP and port - Enabled this port in Windows firewall rules
- Tested remote port access from local machine
- Smoke tests where working as expected like running on localhost
Hi, I am trying to automate the Microsoft LinkedIn application with java -Selenium, WinAppDriver for demo purpose. Application get launch but its getting failed due to Failed to locate opened application window with appId. This error is getting shown. Could you please provide any one suggestion that can help as of now i have tried all the online solutions that are related with this issue.
Hi, I am trying to automate the Microsoft LinkedIn application with java -Selenium, WinAppDriver for demo purpose. Application get launch but its getting failed due to Failed to locate opened application window with appId. This error is getting shown. Could you please provide any one suggestion that can help as of now i have tried all the online solutions that are related with this issue.
@Sameer9767 Please create separate issue, provide code sample, WinAppDriver log