You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Appium WebDriverException: Failed to Locate Application Window for My Own App #2059
Getting error that:
Failed to locate opened application window with appId: C:\Program Files (x86)\FolderPath\MyOwnApp.exe, and processId: 4016�
public WindowsDriver<WindowsElement> GetDriver()
{
AppiumOptions appCapabilities = new AppiumOptions();
appCapabilities.AddAdditionalCapability("app", _winAppSession);
appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
return new WindowsDriver<WindowsElement>(new Uri(_appiumDriverURI), appCapabilities);
}
_winAppSession is path which in this case is C:\\Program Files (x86)\\FolderPath\\MyOwnApp.exe _appiumDriverURI is http://127.0.0.1:4723
This is giving the above mentioned error. After couple of seconds application launches with first showing the splash screen and then it opens the main screen.
Shakevg When the application is started in local server and we are sending the commands using AWS SSM to execute automation using WinAppDriver.
Now after adding the fallback mentioned in in #1737. When i did a RDP into EC2 and then executed the automation, then it is working as expected and able to perform click actions. But when I don't do RDP into EC2 and execute the automation, then it is failing with error An unknown error occurred in the remote end while processing the command�.
Not able to figure out why it is working when I did a RDP into EC2 and failed when I didn't do RDP.
Code After changes
public WindowsDriver<WindowsElement> GetDriver()
{
CheckWinAppDriverInstallation();
try
{
AppiumOptions appCapabilities = new AppiumOptions();
appCapabilities.AddAdditionalCapability("app", _winAppSession);
appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
appCapabilities.AddAdditionalCapability("ms:waitForAppLaunch", "30");
return new WindowsDriver<WindowsElement>(new Uri(_appiumDriverURI), appCapabilities);
}
catch
{
Process MyOwnAppProcess = null;
RetryExecutor retryExecutor = new RetryExecutor(new RetryStrategy(3, TimeSpan.FromSeconds(10)));
retryExecutor.Retry(() =>
{
MyOwnAppProcess = Process.GetProcessesByName("MyOwnApp").FirstOrDefault();
Throw.IfNull(() => MyOwnAppProcess);
});
IntPtr MyOwnAppHandle = IntPtr.Zero;
for (int i = 0; i < 20; i++)
{
MyOwnAppProcess.Refresh();
if (MyOwnAppProcess.MainWindowHandle != IntPtr.Zero)
{
MyOwnAppHandle = MyOwnAppProcess.MainWindowHandle;
break;
}
Thread.Sleep(1000);
}
if (MyOwnAppHandle == IntPtr.Zero)
{
throw new Exception("Failed to get main window handle of MyOwnApp.");
}
string hexHandle = MyOwnAppHandle.ToString("x");
AppiumOptions appCapabilities = new AppiumOptions();
appCapabilities.AddAdditionalCapability("appTopLevelWindow", hexHandle);
appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
return new WindowsDriver<WindowsElement>(new Uri(_appiumDriverURI), appCapabilities);
}
}
Regarding the app, it first starts with splash screen then opens the main screen and there is popup screen for login
When I checked the Windows Application Driver logs, it shows that Driver was created successfully, but when trying to add username to the application it gives 200 but when trying to write value it is giving error.
Login happens in a popup windows with username and password.
Windows Application Driver listening for requests at: http://127.0.0.1:4723/
Press ENTER to exit.
==========================================
POST /session HTTP/1.1
Accept: application/json, image/png
Connection: Keep-Alive
Content-Length: 163
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: d2aebd9a-05ce-4902-b8bc-3d05abc760da
HTTP/1.1 200 OK
Content-Length: 127
Content-Type: application/json
{"sessionId":"557C2584-73E9-45BB-95A6-8A0B24ACC143","status":0,"value":{"appTopLevelWindow":"1904e4","platformName":"Windows"}}
==========================================
POST /session/557C2584-73E9-45BB-95A6-8A0B24ACC143/element HTTP/1.1
Accept: application/json, image/png
Content-Length: 61
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: 5e2368db-dcf0-4276-95ec-dccb2e1a5e9b
{"using":"xpath","value":"//Edit[@AutomationId='_username']"}
HTTP/1.1 200 OK
Content-Length: 96
Content-Type: application/json
{"sessionId":"557C2584-73E9-45BB-95A6-8A0B24ACC143","status":0,"value":{"ELEMENT":"42.1508542"}}
==========================================
POST /session/557C2584-73E9-45BB-95A6-8A0B24ACC143/element/42.1508542/clear HTTP/1.1
Accept: application/json, image/png
Content-Length: 2
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: 10c612e6-d51e-434b-9643-530a6e9370d0
{}
HTTP/1.1 200 OK
Content-Length: 63
Content-Type: application/json
{"sessionId":"557C2584-73E9-45BB-95A6-8A0B24ACC143","status":0}
==========================================
POST /session/557C2584-73E9-45BB-95A6-8A0B24ACC143/element/42.1508542/value HTTP/1.1
Accept: application/json, image/png
Content-Length: 30
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: bf36c6c4-1992-4233-9671-a97faecce106
{"value":["My User Bot"]}
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
Is the login window a window created using winforms, WPF, UWP or the Microsoft authentication. Please also check if the username window is part of the same UI tree or a separate window.
Is the login window a window created using winforms, WPF, UWP or the Microsoft authentication. Please also check if the username window is part of the same UI tree or a separate window.
ANUNAYA THAKUR (@anunay1) It is an external application based on the dependency used System.Windows.Forms. I think it is a winforms application. And username window is part of the same UI tree.
Xpath of the main UI Header: /Pane[@ClassName=\"#54321\"][@Name=\"Desktop 1\"]/Window[@Name=\"AppName\"][@AutomationId=\"ShellFormView\"]
Xpath of the Popup header: /Pane[@ClassName=\"#54321\"][@Name=\"Desktop 1\"]/Window[@Name=\"AppName\"][@AutomationId=\"ShellFormView\"]/Window[@Name=\"AppName Login\"][@AutomationId=\"LoginDialog\"]/TitleBar[@AutomationId=\"TitleBar\"]
Xpath of the username UI: /Pane[@ClassName=\"#54321\"][@Name=\"Desktop 1\"]/Window[@Name=\"AppName\"][@AutomationId=\"ShellFormView\"]/Window[@Name=\"AppName Login\"][@AutomationId=\"LoginDialog\"]/Edit[@AutomationId=\"_username\"]/Edit[starts-with(@ClassName,\"WindowsForms10\")]
Not to get how the WinAppDriver is able to run the automation when manual RDP is done in EC2 instance and fails to create winappdriver instance or not able to write the element when there is no manual RDP.
The error is very clear. Set value method is not supported. Use send keys instead
I have used send keys only still it is giving the same error, but the same code is working fine when there is no manual RDP to the AWS Windows EC2. I feel the issue is not with the code, or we need to make some configuration changes in ec2 or not sure.
Still getting same error : "An unknown error occurred in the remote end while processing the command."
WindowsElement usernameField = _windowsDriver.FindElementByAccessibilityId("_username");
usernameField.Clear();
usernameField.SendKeys("My User Bot");
I have worked on azure VM and it works fine. Not sure about ec2 better ask support from AWS. Also how do you know if the application is even launched when driver is initialised.I had a similar problem and i implemented screen recording and figured out the application is not launched successfully.
I have worked on azure VM and it works fine. Not sure about ec2 better ask support from AWS. Also how do you know if the application is even launched when driver is initialised.I had a similar problem and i implemented screen recording and figured out the application is not launched successfully.
Based on the above logs it seems that session it created and it is able to clear the existing value written in that element. But it is failing when it is trying to set the value to that element. Is there any way to know thrle exact root cause of that error, either by enabling debug logs of the winapp driver to know the exact cause, as it is returning generic error. And not able to figure out ehat can be the probable error.
ANUNAYA THAKUR (@anunay1) I have made some changes and I have added CLI command Start-Process 'tscon' -ArgumentList 'rdp-tcp#0 /dest:console' -Verb runAs to attach console
After making this change before login it is able to perform click actions but after login it is able to find element but when trying to perform click action on the button it is showing error that element is not found. But the same is working when I login to EC2 instance.
It is able to find element //ToolBar[@Name='Modules'] but not able to find //Button[@Name='Payment Manager'] which is inside the Module. Not sure why the same is working when I login to EC2 instance.
==========================================
POST /session/F0DE19E2-A30C-4E35-ABA1-F06784BB9B91/element HTTP/1.1
Accept: application/json, image/png
Content-Length: 60
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: 197a9e11-c911-4ea1-a86a-5faff3699060
{"using":"xpath","value":"//Button[@AutomationId='_login']"}
HTTP/1.1 200 OK
Content-Length: 95
Content-Type: application/json
{"sessionId":"F0DE19E2-A30C-4E35-ABA1-F06784BB9B91","status":0,"value":{"ELEMENT":"42.458818"}}
==========================================
POST /session/F0DE19E2-A30C-4E35-ABA1-F06784BB9B91/element/42.458818/click HTTP/1.1
Accept: application/json, image/png
Content-Length: 2
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: bed96545-22ab-407b-ba7b-c20734cf9078
{}
HTTP/1.1 200 OK
Content-Length: 63
Content-Type: application/json
{"sessionId":"F0DE19E2-A30C-4E35-ABA1-F06784BB9B91","status":0}
==========================================
POST /session/F0DE19E2-A30C-4E35-ABA1-F06784BB9B91/elements HTTP/1.1
Accept: application/json, image/png
Content-Length: 54
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: da58ba1b-273e-42ba-b939-6f6022e546b2
{"using":"xpath","value":"//ToolBar[@Name='Modules']"}
HTTP/1.1 200 OK
Content-Length: 124
Content-Type: application/json
{"sessionId":"F0DE19E2-A30C-4E35-ABA1-F06784BB9B91","status":0,"value":[{"ELEMENT":"42b80c4c-5ef0-422b-873e-e96a112a4a3e"}]}
==========================================
GET /session/F0DE19E2-A30C-4E35-ABA1-F06784BB9B91/element/42b80c4c-5ef0-422b-873e-e96a112a4a3e/displayed HTTP/1.1
Accept: application/json, image/png
Cache-Control: no-cache
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: 82503ea3-857c-48f7-b614-8a860b38048a
HTTP/1.1 200 OK
Content-Length: 76
Content-Type: application/json
{"sessionId":"F0DE19E2-A30C-4E35-ABA1-F06784BB9B91","status":0,"value":true}
==========================================
POST /session/F0DE19E2-A30C-4E35-ABA1-F06784BB9B91/element HTTP/1.1
Accept: application/json, image/png
Content-Length: 61
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: 20d4140f-81e5-4795-b7f5-77d8c0aa4397
{"using":"xpath","value":"//Button[@Name='Payment Manager']"}
HTTP/1.1 404 Not Found
Content-Length: 139
Content-Type: application/json
{"status":7,"value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters."}}
==========================================
DELETE /session/F0DE19E2-A30C-4E35-ABA1-F06784BB9B91 HTTP/1.1
Accept: application/json, image/png
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)
X-Idempotency-Key: cd8c4494-2e1b-4c96-95b5-07e1ec451480
I got way to run the WinAppDriver, I have added CLI command Start-Process 'tscon' -ArgumentList 'rdp-tcp#0 /dest:console' -Verb runAs to attach console of my application. But with tscon, at times it fails to render some nested child elements if they are too nested.
Activity
Shakevg commentedon Jun 2, 2025
#1737 (comment)
Ravit436 commentedon Jun 4, 2025
Shakevg When the application is started in local server and we are sending the commands using AWS SSM to execute automation using WinAppDriver.
Now after adding the fallback mentioned in in #1737. When i did a RDP into EC2 and then executed the automation, then it is working as expected and able to perform click actions. But when I don't do RDP into EC2 and execute the automation, then it is failing with error
An unknown error occurred in the remote end while processing the command�.Not able to figure out why it is working when I did a RDP into EC2 and failed when I didn't do RDP.
Code After changes
Regarding the app, it first starts with splash screen then opens the main screen and there is popup screen for login
Ravit436 commentedon Jun 6, 2025
Shakevg
When I checked the Windows Application Driver logs, it shows that Driver was created successfully, but when trying to add username to the application it gives 200 but when trying to write value it is giving error.
Login happens in a popup windows with username and password.
anunay1 commentedon Jun 13, 2025
Is the login window a window created using winforms, WPF, UWP or the Microsoft authentication. Please also check if the username window is part of the same UI tree or a separate window.
Ravit436 commentedon Jun 20, 2025
ANUNAYA THAKUR (@anunay1) It is an external application based on the dependency used System.Windows.Forms. I think it is a winforms application. And username window is part of the same UI tree.
Xpath of the main UI Header:
/Pane[@ClassName=\"#54321\"][@Name=\"Desktop 1\"]/Window[@Name=\"AppName\"][@AutomationId=\"ShellFormView\"]Xpath of the Popup header:
/Pane[@ClassName=\"#54321\"][@Name=\"Desktop 1\"]/Window[@Name=\"AppName\"][@AutomationId=\"ShellFormView\"]/Window[@Name=\"AppName Login\"][@AutomationId=\"LoginDialog\"]/TitleBar[@AutomationId=\"TitleBar\"]Xpath of the username UI:
/Pane[@ClassName=\"#54321\"][@Name=\"Desktop 1\"]/Window[@Name=\"AppName\"][@AutomationId=\"ShellFormView\"]/Window[@Name=\"AppName Login\"][@AutomationId=\"LoginDialog\"]/Edit[@AutomationId=\"_username\"]/Edit[starts-with(@ClassName,\"WindowsForms10\")]Not to get how the WinAppDriver is able to run the automation when manual RDP is done in EC2 instance and fails to create winappdriver instance or not able to write the element when there is no manual RDP.
anunay1 commentedon Jun 20, 2025
Can you check
https://community.fortra.com/kb-nav/kb-article/?id=548d72cc-68c3-eb11-bacc-000d3a1fe4c0&redirect=false
Also have a look at #147
Ravit436 commentedon Jun 21, 2025
I have made the changes in the registry of windows EC2 as per section
Configuration for all usersin https://community.fortra.com/kb-nav/kb-article/?id=548d72cc-68c3-eb11-bacc-000d3a1fe4c0&redirect=false but I'm still getting the same error when there is no manual RDP in EC2.It is able to clear the value but failing when it is trying to write the value in that element
I did not understand any solution mentioned in #147
anunay1 commentedon Jun 21, 2025
The error is very clear. Set value method is not supported. Use send keys instead
Ravit436 commentedon Jun 21, 2025
I have used send keys only still it is giving the same error, but the same code is working fine when there is no manual RDP to the AWS Windows EC2. I feel the issue is not with the code, or we need to make some configuration changes in ec2 or not sure.
Still getting same error : "An unknown error occurred in the remote end while processing the command."
anunay1 commentedon Jun 21, 2025
I have worked on azure VM and it works fine. Not sure about ec2 better ask support from AWS. Also how do you know if the application is even launched when driver is initialised.I had a similar problem and i implemented screen recording and figured out the application is not launched successfully.
Ravit436 commentedon Jun 21, 2025
Based on the above logs it seems that session it created and it is able to clear the existing value written in that element. But it is failing when it is trying to set the value to that element. Is there any way to know thrle exact root cause of that error, either by enabling debug logs of the winapp driver to know the exact cause, as it is returning generic error. And not able to figure out ehat can be the probable error.
anunay1 commentedon Jun 21, 2025
Better implement screen recording. Depending on the language binding won't take much effort.
anunay1 commentedon Jun 21, 2025
Usually I used to get this error either WinAppDriver.exe crashed or the system got locked.
Ravit436 commentedon Jun 22, 2025
ANUNAYA THAKUR (@anunay1) I have made some changes and I have added CLI command
Start-Process 'tscon' -ArgumentList 'rdp-tcp#0 /dest:console' -Verb runAsto attach consoleAfter making this change before login it is able to perform click actions but after login it is able to find element but when trying to perform click action on the button it is showing error that element is not found. But the same is working when I login to EC2 instance.
It is able to find element
//ToolBar[@Name='Modules']but not able to find//Button[@Name='Payment Manager']which is inside the Module. Not sure why the same is working when I login to EC2 instance.Ravit436 commentedon Jul 4, 2025
I got way to run the WinAppDriver, I have added CLI command
Start-Process 'tscon' -ArgumentList 'rdp-tcp#0 /dest:console' -Verb runAsto attach console of my application. But with tscon, at times it fails to render some nested child elements if they are too nested.anunay1 commentedon Jul 4, 2025
Are you using xpath then it will be too slow. Try using some other methods like name, automation ID etc...