Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appium.WebDriver@5.0.0 compatibility with WinAppDriver #487

Closed
dtopuzov opened this issue Nov 28, 2021 · 20 comments
Closed

Appium.WebDriver@5.0.0 compatibility with WinAppDriver #487

dtopuzov opened this issue Nov 28, 2021 · 20 comments

Comments

@dtopuzov
Copy link

Description

Appium.WebDriver@5.0.0-beta01 can not work with https://github.com/microsoft/WinAppDriver directly.
The reason is WinAppDriver want app capability to be set, while Appium.WebDriver prefix and makes it appium:app.

Referace:
https://github.com/appium/appium-dotnet-driver/blob/release/5.0.0/src/Appium.Net/Appium/AppiumOptions.cs#L15

To keep compatiblity with WinAppDriver I would like to have a way to create cabalities object that allows me to have app with the prefix.

I understand that ideally the fix should be on WinAppDriver side, but currently it still using deprecated JSON wire protocol :(

Environment

  • .NET client build version or git revision if you use some shapshot: Appium.WebDriver@5.0.0-beta01
  • Appium server version or git revision if you use some shapshot: appium@2.0.0-beta.23
  • Desktop OS/version used to run Appium if necessary: Windows 10/11
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 14
  • Mobile platform/version under test: Windows Desktop

Details

The use case is:

  • I try to build cross platform automation for Android/iOS/MacOS/Windows via Appium
  • For Windows I tries to use https://github.com/microsoft/WinAppDriver directly because I had issues when using via appium.
@mykola-mokhnach
Copy link

I don't see any point in adding the support of the legacy JWP protocol into the driver just because Microsoft has abandoned the support for their WAD server. Also, it still works being used together with Appium as the latter is capable of requests transformation between W3C<>JWP.

@mykola-mokhnach
Copy link

You could also consider creating a fork of the project

@mg-diego
Copy link

Hi! Any news on this topic? I'm facing the same problem on my project and so far we could not find any solution in order to be able to use our WinAppDriver testcases in case we migrate to Selenium v4 + Appium driver.

Thanks in advance

@TroyWalshProf
Copy link
Contributor

@dtopuzov
The beta kind of work with WinAppDriver, as long as you are interacting with it thru the Appium client.
Here is roughly how to get and run the Appium client

npm install -g appium # get appium
npm install wd # get appium client
appium & # start appium

Note* Basically all "Action" calls will fail, see:
microsoft/WinAppDriver#1610
appium/appium#16268

@grokys
Copy link

grokys commented Oct 26, 2022

Is my current understanding of the state of Appium/WinAppDriver correct?

So essentially, we're forced into a choice:

  • Stay with unsupported Appium 1.0, or
  • Lose support for testing mouse and keyboard events

Is this accurate?

@Dor-bl
Copy link
Collaborator

Dor-bl commented Oct 30, 2022

@grokys 5.0.0 beta worked for me with winapp driver. Can you please give an example what is not working for you?

@grokys
Copy link

grokys commented Nov 2, 2022

@Dor-bl I'm seeing the problem described by this issue:

The reason is WinAppDriver want app capability to be set, while Appium.WebDriver prefix and makes it appium:app.

Specifically, I see:

Windows Application Driver listening for requests at: http://127.0.0.1:4723/
Press ENTER to exit.


==========================================
POST /session HTTP/1.1
Accept: application/json; charset=utf-8
Content-Length: 249
Content-Type: application/json; charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/4.0.0 (.net windows)
X-Idempotency-Key: def0c1a2-c88f-4d06-9c73-ceff3c423fbe

{"capabilities":{"firstMatch":[{"platformName":"Windows","appium:app":"D:\\projects\\AvaloniaUI\\Avalonia\\samples\\IntegrationTestApp\\bin\\Debug\\net6.0\\IntegrationTestApp.exe","appium:automationName":"Windows","appium:deviceName":"WindowsPC"}]}}
HTTP/1.1 400 Bad Request
Content-Length: 141
Content-Type: application/json

{"status":100,"value":{"error":"invalid argument","message":"Bad capabilities. Specify either app or appTopLevelWindow to create a session"}}

@yizhao5
Copy link

yizhao5 commented Nov 3, 2022

@Dor-bl. Hello. How did you work successfully in version v5.0.0-beta02?

Description
The basic function of constructing WindowsDriver with appium-dotnet-driver's version v5.0.0-beta02 goes error.
image
Error log:
{"status":100,"value":{"error":"invalid argument","message":"Bad capabilities. Specify either app or appTopLevelWindow to create a session"}}

Version
OS: Windows 11.
dotnet: .NET Framework 4.7.2
WinAppDriver: WinAppDriver v1.2.1.
appium: use VS Nuget cmd: NuGet\Install-Package Appium.WebDriver -Version 5.0.0-beta02

Repro Steps

  1. create a VS 2022 console project.
    image
  2. sample code:
    Program.cs
using OpenQA.Selenium.Appium.Windows;
using System;

namespace ConsoleApp1
{
	internal class Program
	{
		static void Main(string[] args)
		{
			const string appId = @"C:\Program Files\WindowsApps\Microsoft.WindowsNotepad_11.2208.25.0_x64__8wekyb3d8bbwe\Notepad\Notepad.exe";

			var appiumOptions = new OpenQA.Selenium.Appium.AppiumOptions();
			appiumOptions.App = appId;
			var _ = new WindowsDriver(new Uri("http://127.0.0.1:4723"), appiumOptions);
		}
	}
}
  1. first click C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe, then click the VS 2022's Start button to launch, and an error occurred.
    image

@Dor-bl, @akinsolb, @licanhua, @timotiusmargo. Can you fix it? Or just upgrade the current Appium.WebDriver 4.4.0's internal dependency package Selenium.WebDriver 3.141.0 to Selenium.WebDriver 4.5.1, so that users can use the latter's new features, such as EdgeOptions.UseWebView = true;. Thanks.

Similar issue:
WinAppDriver using deprecated JSON wire protocol #1610
Error raised when launching the app: Specify either app or appTopLevelWindow to create a session #1774
Unable to Initiate Session with WinAppDriver #1592
OpenQA.Selenium.WebDriverArgumentException: Bad capabilities. Specify either app or appTopLevelWindow to create a session #492

@licanhua
Copy link

licanhua commented Nov 3, 2022

@yizhao5 I guess you didn't use appium or something is wrong in the middle. WinAppDriver is expecting app: other than appium:app, so you may remove appium prefix and try again?

image

@yizhao5
Copy link

yizhao5 commented Nov 3, 2022

@licanhua, thanks for your reply. Yes, appium-dotnet-driver v5.0.0-beta02 has been refactored. The prefix appium: is automatically added in the appium-dotnet-driver v5.0.0-beta02.
image
I listed the Repro Steps above, and similar issues all have the same error log Bad capabilities. Specify either app or appTopLevelWindow to create a session.

@Dor-bl. The customers' requirement is hoping to use new features of Selenium 4. The function of Appium.WebDriver 4.4.0 is good enough. Can you upgrade its internal dependency package Selenium.WebDriver from 3.141.0 to 4.5.1? Thanks.

@Dor-bl
Copy link
Collaborator

Dor-bl commented Nov 3, 2022

Indeed, I can see this error as well.
I Didn't have it while using Appium1.0, but Apparently something related to Appium 2.0.
@akinsolb I'm looking into it, but if you can have a look as well that would be great.
in the meantime, we can add the bug label to this issue.
EDIT:
Actually, I see what you mean, this is occurring when going through winAppDriver server itself and not the appium server.
I see that when we pass "app" as cap, for some reason it disappears along the way from the session parameter

@Dor-bl
Copy link
Collaborator

Dor-bl commented Jan 1, 2023

@yizhao5 looking over at your comment it's not possible to update the dependency package of Selenium.WebDriver from 3.141.0 to 4.5.1 since it will break the stable release.
if users want to use the latest version of Selenium.WebDriver they will need to use the Beta release of the Appium.WebDriver

@kfertitta
Copy link

@Dor-bl We're running WinAppDriver (1.2.1) alone as we're only testing desktop apps. I'm still seeing this issue with 5.0.0-beta03. Been pouring over the various issues and discussions and it's not clear (to me, anyway) which Appium.WebServer version should go with which WinAppDriver version. I'm also trying to get info from the WinAppDriver side of the fence.

Our UI tests and page object models are growing rapidly, so we want try to get on a sustainable path. There were a lot of code changes going from the old Microsoft.WinAppDriver.Appium.WebDriver preview, so it's a big switch we have to flip. Any thoughts and guidance are much appreciated.

@Dor-bl
Copy link
Collaborator

Dor-bl commented Mar 6, 2023

@kfertitta Sorry for the late response, basically as long as Microsoft doesn't decide to allocate resources to the WinAppDriver projects our hands are tied here since the Appium-DotNet client fully supports W3C protocol while the WinAppDriver doesn't.
regardless of the latest version of the DotNet client removed any support for page object models.
My suggestion to you is to raise issues on the WinAppDriver and hope for someone at Microsoft to notice :(

@Dor-bl Dor-bl added the W3C label Mar 6, 2023
@kfertitta
Copy link

@Dor-bl Thanks much for the reply. Indeed, we are trying to get attention on the Microsoft side. It is the only way this can move forward it seems. As our UI testing code base grows, we continually question if it's wise to continue to build upon a foundation that has such a questionable future. And yet, there doesn't really seem to be a better alternative out there for desktop testing. Though we're willing to pay for a commercial solution, I'm not convinced those would actually be as good. Hard to know where to go from here.

@Dor-bl
Copy link
Collaborator

Dor-bl commented Mar 6, 2023

@kfertitta I took a quick look again at my configuration when running the Windows Integration tests, maybe this will assist you.

Appium Server v2.0.0-beta.xx
Appium Windows Driver windows@2.1.2
WinAppDriver v1.2.1

with the above configuration, I was able to run a basic test even when I pass appium:app
image

@Dor-bl
Copy link
Collaborator

Dor-bl commented Apr 7, 2023

@Schepetkov in order to use "appium:app" you will need to start the Appium server that will act as a proxy, rather than starting the WinAppDriver

@Dor-bl
Copy link
Collaborator

Dor-bl commented May 4, 2024

I am closing this issue since Microsoft has no intentions of maintaining its WinAppDriver in the near future.
I found that https://github.com/FlaUI/FlaUI.WebDriver might be a good option for those looking to Automate Windows Applications with W3C compatibility.

@Dor-bl Dor-bl closed this as not planned Won't fix, can't repro, duplicate, stale May 4, 2024
@PeterExtrapreneur
Copy link

I am closing this issue since Microsoft has no intentions of maintaining its WinAppDriver in the near future. I found that https://github.com/FlaUI/FlaUI.WebDriver might be a good option for those looking to Automate Windows Applications with W3C compatibility.

So the only way forward for projects that has UWP and WPF that use Selenium/Appium is to refactor to FlaUI? Appium v5 left WAD and seleniums action class is also deprecated.

@Dor-bl
Copy link
Collaborator

Dor-bl commented Jul 17, 2024

@PeterExtrapreneur, I didn't drop WAD from v5; I don't see a reason to maintain that driver if Microsoft doesn't, either.
Indeed, I suggest you migrate to FlaUI. If you have issues or adjustments, you can always open a ticket on their side. They are pretty responsive and open-minded about making it work with the Appium dotnet client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants