WinAppDriver
WinAppDriver copied to clipboard
WinAppDriver using deprecated JSON wire protocol
This driver is still using the old JsonWireProtocol, which is obsolete . The driver should get updated to the W3C standard standard.
Notes*
- Without this update new version of Appium many not be able to work with WinAppDriver.
- The Edge WebDriver is already W3C compliant so I am guessing @bwalderman may have some sort of cheatsheet or guidance for becoming W3C compliant.
Have you tried
appCapabilities.SetCapability("ms:experimental-webdriver", true);
I tried with both https://github.com/microsoft/WinAppDriver/releases/tag/v1.2.1 and https://github.com/microsoft/WinAppDriver/releases/tag/v1.2.99
When I try to connect using a compliant session JSON I get:
{"status":100,"value":{"error":"invalid argument","message":"Bad capabilities. Specify either app or appTopLevelWindow to create a session"}}
Notes*
-
Here is what the start session json body, which works using Appium, looks like
{"capabilities":{"firstMatch":[{"platformName":"Windows","appium:app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:deviceName":"WindowsPC","ms:experimental-webdriver":true}]}}
-
Also, when we find an element we would expect to get the response in this format:
{"value":{"element-6066-11e4-a52e-4f735466cecf":"VALUE.VALUE","ELEMENT":"VALUE.VALUE"}}
or{"value":{"element-6066-11e4-a52e-4f735466cecf":"VALUE.VALUE"}}
Per the W3C standard But it comes back in this format{"sessionId":"GUID","status":0,"value":{"ELEMENT":"VALUE.VALUE"}}
-
Jonathan Lipps does a really good job out outline when Appium drives need to know about adhering to the W3C standard https://github.com/jlipps/simple-wd-spec
@licanhua
@TroyWalshProf the best cheat sheet I can point you to for W3C compliance is the webdriver spec itself as this is what we used to update the legacy Edge implementation (MicrosoftWebDriver). Our current implementation is inherited from the Chromium project so I wasn't involved in their efforts to match the spec.
In MicrosoftWebDriver, we treat "w3c" and "jwp" (JSON wire protocol) as two separate "dialects" the client may use, but the underlying implementation of the commands is the same. If we detect the client is using W3C-style capabilities in their session request then we switch to w3c mode. The mode determines what commands are available. For example, actions is only available in w3c mode. For commands that are common between both w3c and jwp dialects (such as click), there is only one actual command implementation and the only difference is how the parameters are parsed. The dialect that the client choses will also affect how results and errors are returned. For example, JWP uses numeric error codes but W3C uses strings. Either way, the internal representation of errors in our C++ code is the same, and the choice of dialect only affects how they are rendered in the HTTP response.
@bwalderman - That is great news. So how does WinAppDriver detect that the you are using using W3C-style capabilities? AKA what JSON body would you expect *Hopefully I am just doing something dumb
@TroyWalshProf Are you using appium to connect with WinAppDriver? ms:experimental-webdriver mimics some of the response of W3c, but not all of them.
For {"status":100,"value":{"error":"invalid argument","message":"Bad capabilities. Specify either app or appTopLevelWindow to create a session"}}
, likely you send the appium message directly to WinAppDriver without appium.
Please remove the appium:
prefix in capabilities. appium will remove the prefix before it forwards message to WinAppDriver. but you didn't start appium, it's expected to run into error.
Here is the capabilities I used long time ago to support both appium and without appium connection(I don't know if it's still compatible with appium). Please pay attention to appium:app
and app
platformName: 'windows',
'appium:deviceName': 'WindowsPC',
'appium:app': 'ReactUWPTestApp_cezq6h4ygq1hw!App',
'deviceName': 'WindowsPC',
'app': 'ReactUWPTestApp_cezq6h4ygq1hw!App',
'winAppDriver:experimental-w3c': true,
This is only an issue when connecting to the WinAppDriver directly.
A little more context:
The Appium.Net team is working on an a Selenium 4 related update. The Selenium 4 changes have affected the format of the new session JSON body.
*For better or worse we are largely tied to the Selenium project when it comes to the JSON body format.
I have been unable to make this format work with WinAppDriver 1.2.1 or 1.2.99 Unless I can find a good solution, the next release of Appium.Net will not be able to work with WinAppDriver directly.
Here are the new session bodies I have tried:
{"capabilities":[{"platformName":"Windows","appium:app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:deviceName":"WindowsPC","winAppDriver:experimental-w3c":true}]}
{"capabilities":[{"platformName":"Windows","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:deviceName":"WindowsPC","winAppDriver:experimental-w3c":true}]}
{"capabilities":{"firstMatch":[{"platformName":"Windows","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:deviceName":"WindowsPC","winAppDriver:experimental-w3c":true}]}}
{"capabilities":{"firstMatch":[{"platformName":"Windows","app":"Microsoft.WindowsCalculator_8wekyb3d8bbwe!App","appium:deviceName":"WindowsPC","winAppDriver:experimental-w3c":true}]}}
And not to be that guy, but it seems like things would be a little easier if WinAppDriver was actually open source :)
@licanhua
I'm digging into this right now so that I can form an engineering plan for updating it. This is a lot, and I can't promise that my nascent familiarity with the codebase is going to be of much help. Stay tuned. :smile:
Great to hear someone is working on this. Hope it's feasible to figure out a solution for this.
@DHowett Really great to hear, thank you for the update.
@DHowett - Any update on this?
@DHowett - Is this a dead project?
any updates?
Bueller, Bueller, Bueller, Bueller Anyone? Bueller
who is working on this? I had to downgrade everything for it to work.
Instead of the direct connection with WinAppDriver, you can use Appium as the bridge between. I saw appium-windows-driver is open sourced and supports W3C
Here are two kinds of connections:
- client <-> appium <-> appium-windows-driver <-> WinAppDriver
- client <-> WinAppDriver
@licanhua - using the Appium client works-ish Basically you are fine until you need to leverage actions: https://github.com/appium/appium/issues/16268
Apparently, the community projects like Appium iterate faster than WinAppDriver. My opinion:
- Keep your test framework in old version, and wait for WinAppDriver fix
- Alternatively, you may drive and fix it from the community side and contribute your fix to existing open-source projects. I don't think Appium accepts deprecated JWP PRs, so appium-windows-driver or other open-source project are your options.
appium-windows-driver
plays some magic in the middle which can convert W3C action chains to JWP ones, so it's possible for you to fix it here too.
The second one is the one you can see the progress and control it fully from your side.
@licanhua Thank you for the advice. I will test. I've already downgraded so it'll be in the future. I'm an amateur at this. Trying to set up automated QA as a side project for the company I work at.
Instead of the direct connection with WinAppDriver, you can use Appium as the bridge between. I saw appium-windows-driver is open sourced and supports W3C
Here are two kinds of connections:
- client <-> appium <-> appium-windows-driver <-> WinAppDriver
- client <-> WinAppDriver
Hi @licanhua Could you, please, drive me in the direction of the first approach? How do I use Appium as the bridge?
At this point, I have a Java project with appium.java_client dependency and when I create WindowsDriver I pass the URL to where WinAppDriver is running. Should have an Appium server running as well? And if so - how would I redirect requests from the Appium server to WinAppDriver? Or does it run WinAppDriver somewhere inside?
Please follow https://github.com/microsoft/WinAppDriver/blob/master/Docs/UsingAppium.md
Awesome, I'll follow it. Thanks a lot!
@licanhua
Apparently, the community projects like Appium iterate faster than WinAppDriver. My opinion:
- Keep your test framework in old version, and wait for WinAppDriver fix
- Alternatively, you may drive and fix it from the community side and contribute your fix to existing open-source projects. I don't think Appium accepts deprecated JWP PRs, so appium-windows-driver or other open-source project are your options.
appium-windows-driver
plays some magic in the middle which can convert W3C action chains to JWP ones, so it's possible for you to fix it here too.The second one is the one you can see the progress and control it fully from your side.
is there any example how to use it in java project? I'm totaly lost with node !!
Maybe you can start with Java Sample
Is there any update on this? Can we now use WinAppDriver with Selenium 4?
@licanhua @DHowett I can help you guys to reproduce the problem in debug mode (if you have issue in that), you can contact me on email: [email protected] thanks.
Hi guys, Is there any example out there how to use winappdriver without appium when trying to automate windows applications? I couldn't find anything. Any help will be appreciated
Hi guys, Is there any example out there how to use winappdriver without appium when trying to automate windows applications? I couldn't find anything. Any help will be appreciated
@jonathangiber yes, you should use the same appium python libs, but connect to WinAppDriver
server instead of appium
server. Launch the WinAppDriver
server from cli.
You can reach me in LinkedIn if you are stuck.