microsoft / WinAppDriver

Windows Application Driver
MIT License
3.7k stars 1.41k forks source link

Alternatives to ms:waitForAppLaunch capability, capability is a hard wait and not something that should be used #1507

Open Tree55Topz opened 3 years ago

Tree55Topz commented 3 years ago

One of the most common problems I run into with WinAppDriver is the "Failed to locate opened application window with appId" error that get thrown when first trying to initiate the session.

I have try catch logic around this that attempts to catch that error and re create the session but this does not work every time and will occasionally bug out my tests.

What we need is a way to tell WinAppDriver to wait UP TO a certain amount of time and not a hard coded wait. The only solution I found is to use this approach which is a hard wait..

appCapabilities.AddAdditionalCapability("ms:waitForAppLaunch", "30");

This is a terrible approach as the app sometimes loads faster or slower and we should not always wait 30 seconds. Implicit waits are crucial for automated UI tests and currently I have not found a way to do this with WinAppDriver. Has anyone else had similar issues or workarounds?

anunay1 commented 3 years ago

@Tree55Topz I implemented a polling mechanism to check if the app is launched or not.

Tree55Topz commented 3 years ago

@anunay1 is that included with the capability I mentioned in the issue or do you just mean by default? Currently, it seems like WinAppDriver will wait up to like 10 seconds or so before throwing that error. Sometimes thats not enough.