Internal Error while starting the application
I am getting internal error from the WinAppDriver. The app is an exe file, but its open a terminal window and it starts a java application(as another process).
My intention was to start the exe and use Root to perform the action on the java UI. WinAppDriver dose not provide a helpful log information to do the further analysis, in this case. Can you please give a resolution to this issue?
POST /session HTTP/1.1 Accept-Encoding: gzip,deflate Connection: Keep-Alive Content-Length: 68 Content-Type: application/json; charset=utf-8 Host: 127.0.0.1:4723 User-Agent: Apache-HttpClient/4.5.1 (Java/1.8.0_91)
SessionManager - Creating session SessionManager - WinAppDriver succeeded loading MitaBroker HTTP/1.1 500 Internal Error Content-Length: 133 Content-Type: application/json
How about starting the exe using java Process and ProcessBuilder class (If u are not automating the exe) and then use "Root" to play around that java application. Make sure you have fewer applications running in your system when you execute the code.
Hello @randikaf,
The session creation above failed to locate the main window due to the complexity of your application launch sequence. The good news is, the latest Windows Application Driver release v1.0-RC will give you more details on such error. In addition, this new release also comes with Attaching to an Existing App Window feature that I believe will serve your scenario well.
Based on the information you provided above, below is how I would setup your application session creation:
// Create a session for Desktop simply to locate the Java UI window after it is launched
DesiredCapabilities desktopCapabilities = new DesiredCapabilities();
desktopCapabilities.SetCapability("app", "Root");
DesktopSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), desktopCapabilities);
Assert.IsNotNull(DesktopSession);
// Launch your application in a try catch so that it won't break the flow on session creation failure.
// We expect this session creation to fail but this is still a better way to start your application remotely.
// For instance, when you are running this test from a separate machine, the session creation will create
// the process, terminal window, and the Java app on the test machine. Using a Process/ProcessBuilder
// class will only work if the test runner is running the test locally in the same machine.
try
{
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "YourApp.exe");
var session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
}
catch { }
// Wait for however long needed for the Java UI to be launched
System.Threading.Thread.Sleep(10000);
var javaAppWindow = DesktopSession.FindElementByName("JavaAppWindowName");
var javaAppTopLevelWindowHandle = javaAppWindow.GetAttribute("NativeWindowHandle");
// Create session from existing top level window above
DesiredCapabilities appCapabilities = new DesiredCapabilities();
javaAppTopLevelWindowHandle = (int.Parse(javaAppTopLevelWindowHandle)).ToString("x");
appCapabilities.SetCapability("appTopLevelWindow", javaAppTopLevelWindowHandle);
var session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Assert.IsNotNull(session);
// At this point you will have a fully working session that you can interact with isolation from other apps