dotnet-client icon indicating copy to clipboard operation
dotnet-client copied to clipboard

[email protected] compatibility with WinAppDriver

Open dtopuzov opened this issue 4 years ago • 17 comments

Description

[email protected] 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: [email protected]
  • Appium server version or git revision if you use some shapshot: [email protected]
  • 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.

dtopuzov avatar Nov 28 '21 15:11 dtopuzov

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 avatar Nov 28 '21 16:11 mykola-mokhnach

You could also consider creating a fork of the project

mykola-mokhnach avatar Nov 28 '21 16:11 mykola-mokhnach

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

mg-diego avatar Jan 17 '22 15:01 mg-diego

@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: https://github.com/microsoft/WinAppDriver/issues/1610 https://github.com/appium/appium/issues/16268

TroyWalshProf avatar Feb 01 '22 14:02 TroyWalshProf

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?

grokys avatar Oct 26 '22 08:10 grokys

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

Dor-bl avatar Oct 30 '22 03:10 Dor-bl

@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"}}

grokys avatar Nov 02 '22 11:11 grokys

@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

yizhao5 avatar Nov 03 '22 04:11 yizhao5

@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

licanhua avatar Nov 03 '22 05:11 licanhua

@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.

yizhao5 avatar Nov 03 '22 06:11 yizhao5

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 avatar Nov 03 '22 09:11 Dor-bl

@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

Dor-bl avatar Jan 01 '23 10:01 Dor-bl

@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.

kfertitta avatar Jan 12 '23 14:01 kfertitta

@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 avatar Mar 06 '23 18:03 Dor-bl

@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.

kfertitta avatar Mar 06 '23 18:03 kfertitta

@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 [email protected] 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 avatar Mar 06 '23 18:03 Dor-bl

@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 avatar Apr 07 '23 05:04 Dor-bl

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 avatar May 04 '24 18:05 Dor-bl