Winappdriver: failed to Locate opened application window ?

Created on 27 Mar 2019  Â·  17Comments  Â·  Source: microsoft/WinAppDriver

POST /session HTTP/1.1
Accept: application/json, image/png
Connection: Keep-Alive
Content-Length: 241
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723

HTTP/1.1 500 Internal Error
Content-Length: 169
Content-Type: application/json

{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: C:\Jericho\JerichoLauncher.exe, and processId: 20108"}}

Most helpful comment

I am running into a similar issue. I found a temporary solution to figure out.

try {
       driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);   
 }
catch (Exception e){
       driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);    
 }

All 17 comments

Capture

Applications opens up after getting system.invalidOperationException.How to resolve this issue?

Is there an update on the issue?
I am facing this same problem when trying to execute the WinAppDriver tests on Bamboo.
Locally the tests work OK.

@CataUdrea How are you able to run locally?

On my local machine, the tests are executed without any issues. I only get this problem when executing the tests on Bamboo.

I implemented the following steps:

  • I start the winAppDriver
  • define capabilities
  • launch the app
capabilities.setCapability("platformName", "Windows");
capabilities.setCapability("deviceName", "WindowsPC");
capabilities.setCapability("app", applicationUnderTest);
windowsApplicationDriver = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
windowsApplicationDriver.launchApp();

I get the error from above only on Bamboo

I am still getting that error message.Would you mind sharing your email
address?

On Thu, Apr 11, 2019 at 8:06 AM CataUdrea notifications@github.com wrote:

On my local machine, the tests are executed without any issues. I only get
this problem when executing the tests on Bamboo.

I implemented the following steps:

  • I start the winAppDriver
  • define capabilities
  • launch the app

capabilities.setCapability("platformName", "Windows");
capabilities.setCapability("deviceName", "WindowsPC");
capabilities.setCapability("app", applicationUnderTest);
windowsApplicationDriver = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
windowsApplicationDriver.launchApp();

I get the error from above only on Bamboo

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/WinAppDriver/issues/641#issuecomment-482105971,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ArToDqOsaf6IlaXCanzsRFR8I8eqBYCmks5vfzM-gaJpZM4cO3AZ
.

Any update on this issue? I'm running into similar issue when running tests in jenkins. The tests work perfectly when I run it locally.
One thing I noticed is that my app starts as a background process when running via jenkins script, not very sure if that might be a cause

I am running into similar issue with jenkins. Any updates would be great.

I just reached this bug after sucesfully making few automated clicks work yesterday. Logging into app, having fun on login screen. Targeting proper .exe file as yesterday, nothing changed and yet application fails to start and I get same error as you:
[STDOUT] {"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: my path to .exe..

I am running into a similar issue. I found a temporary solution to figure out.

try {
       driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);   
 }
catch (Exception e){
       driver = new WindowsDriver(new URL("http://127.0.0.1:4723"), cap);    
 }

Any update on this? I also have this, the tests run fine on my local with both mvn command in within Intellij IDE, but when I execute it on jenkins, it produces this.

I set up my locale machine as a jenkins node and run on this node too, the problem persists though. I tried to get into the jenkins workspace on my local machine, and run the same command I ran on jenkins, and the tests run just fine. So this problem happens on jenkins only.

Please suggest at least a workaround for this.

Any update on this? I also have this, the tests run fine on my local with both mvn command in within Intellij IDE, but when I execute it on jenkins, it produces this.

I set up my locale machine as a jenkins node and run on this node too, the problem persists though. I tried to get into the jenkins workspace on my local machine, and run the same command I ran on jenkins, and the tests run just fine. So this problem happens on jenkins only.

Please suggest at least a workaround for this.

you can have a try to add try-catch. when some Exception happen, renew a driver instance, just a try, it's suited for me

@lucas234 solution worked (try/catch).

See my releases logs it it helps... https://dev.azure.com/jonwolfdev/SimpleWPFTimer/_release?definitionId=1&view=mine&_a=releases

I have a clean working solution in Java using the jna library to get the Native Window Handle dynamically and pass it to Desired Capabilities. You will need to use inspect.exe or another similar tool the first time to get the window name, but after that you're done. The only thing is, instead of launching your app with the WinAppSession you need to do it with a Process Builder and use the desired capability of "appTopLevelWindow" like this:

ProcessBuilder pb = new ProcessBuilder();
            String folder  = "Users\\MyAppFolder";
            pb.command(folder +"Myapp.exe");
            pb.start();
            Thread.sleep(7000);

            windowHandle = JNA_Test2.getHex();

            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability("appTopLevelWindow", windowHandle);
            capabilities.setCapability("platformName", "Windows");
            capabilities.setCapability("deviceName","WindowsPC");
           driver = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4728"), capabilities);

```
public class JNA_Test2 {

    public static String  getHex() {
        Pointer foundWindowPointer = new Memory(4096);
        JNA_Test2.isWindowOpen("My app window name", foundWindowPointer);
        String handle = null;
        if (foundWindowPointer.getPointer(0) != null) {
            WinDef.HWND foundWindow = new WinDef.HWND(foundWindowPointer.getPointer(0));
            handle = String.valueOf(foundWindow);
        }
        return handle.substring(7);

    }
    public static void main(String []args){
        getHex();
    }
Here is the maven dependency of jna to add to your pom file:
 ```
<dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna-platform</artifactId>
            <version>5.5.0</version>
        </dependency>

Try to include below capability which solved my issue of Failed to locate opened application window with appId"xxx" and process "xxx"

My exe file present in C:\Program Files\MT

appCapabilities.SetCapability("appWorkingDir", "C:\Program Files\MT");

Hi ,
Im also facing the similar issue. "Failed to locate opened application window with appId:" . sometimes its launched but not able to see the launched application. so getting "element not found " error.
Im trying to automate the applciaion that was developed by Eclipse RCP and launching the exe file to test.

Run your WinApp driver and eclipse as an administrator. this solved my problem of launching the application.

Was this page helpful?
0 / 5 - 0 ratings