microsoft / WinAppDriver

Windows Application Driver
MIT License
3.69k stars 1.4k forks source link

Create a WindowsDriver Session for a Prelaunched UWP App #566

Open TDWrex opened 5 years ago

TDWrex commented 5 years ago

With the Appium 3.0.0.2 and WinAppDriver 1.1.1809.18001, my team and I have tried to create the WindowsDriver for our application and have noticed some inconsistencies, resulting intermittently in the notorious error:

{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: XXX, and processId: XXX"}}

. When we run our test in Release, we see this error. However, we are able to get successful runs when running these same tests in Debug. Using the Test Manager, my team discovered that the application being tested will be opened as a 'Background process' and become suspended. After searching the web, we discovered that UWP apps in Windows 10 can be prelaunched, which will launch them as a background process and suspend them while the application is setting up. Running tests in debug prevents the app from being prelaunched, since, per Microsoft,

A note about debugging using Visual Studio: Visual Studio prevents Windows from suspending an app that is attached to the debugger. This is to allow the user to view the Visual Studio debug UI while the app is running. When you're debugging an app, you can send it a suspend event using Visual Studio. Make sure the Debug Location toolbar is being shown, then click the Suspend icon.”

Is there currently a way to ensure the WindowsDriver session will prevent the UWP application it is launching from becoming suspended?

hassanuz commented 5 years ago

Hi @TDeBarr,

This is interesting - what are you using to declare the the application session? The appID found in the manifest? Are you able to launch the Release version of the app manually (outside of VS)?

There is no way right now for WinAppDriver to define app launch behavior as of now.