As someone who is fairly new to working with JS and WinAppDriver, I am currently facing a challenge with testing a Windows-based "Click Once" application built on .Net. To launch this application, I have to navigate to a website through Internet Explorer and click on the "Install" button, which then opens up the application.
Once the application is up and running, I find myself unable to establish a connection for performing UI interactions using JavaScript. In the past, I used C# to loop through processes, search for a specific process name, grab its window handle, convert it to hexadecimal, add it as a capability, and create the driver - all successfully. Sample code snippet provided below:
public Setup_TearDown()
{
string TopLevelWindowHandleHex = null;
IntPtr TopLevelWindowHandle = new IntPtr();
foreach (Process clsProcess in Process.GetProcesses())
{
if (clsProcess.ProcessName.StartsWith($"SomeName-{exec_pob}-{exec_env}"))
{
TopLevelWindowHandle = clsProcess.Handle;
TopLevelWindowHandleHex = clsProcess.MainWindowHandle.ToString("x");
}
}
var appOptions = new AppiumOptions();
appOptions.AddAdditionalCapability("appTopLevelWindow", TopLevelWindowHandleHex);
appOptions.AddAdditionalCapability("ms:experimental-webdriver", true);
appOptions.AddAdditionalCapability("ms:waitForAppLaunch", "25");
AppDriver = new WindowsDriver<WindowsElement>(new Uri(WinAppDriverUrl), appOptions);
AppDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
}
However, my struggle lies in replicating this functionality in Javascript. Despite searching extensively, I failed to locate any relevant code examples. Referring to an example from this repo, I attempted the following approach in JS without achieving success:
import {By2} from "selenium-appium";
// Snippet of code for connecting to the application
async connectAppDriver(){
// Code block for finding the process to latch onto
}
Unfortunately, I keep encountering an error message in WinAppDriver that reads:
{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
This issue has been documented and reported under this ticket here, but I am still seeking a solution.
If anyone knows of any node packages or methods that could simplify obtaining the top-level window handle, I would greatly appreciate your suggestions. I am open to exploring alternative approaches in tackling this challenge when using JavaScript for WinAppDriver.