From 25e734a186c6941241e5b056770c8feff65114a3 Mon Sep 17 00:00:00 2001 From: James Croft Date: Fri, 15 Mar 2024 07:18:56 +0000 Subject: [PATCH] Add support to run appium-windows-driver for Windows apps --- src/Legerity.Core/Android/AndroidAppManagerOptions.cs | 5 ----- src/Legerity.Core/AppManager.cs | 4 ++-- src/Legerity.Core/AppiumManagerOptions.cs | 5 +++++ src/Legerity.Core/IOS/IOSAppManagerOptions.cs | 5 ----- src/Legerity.Core/Windows/Helpers/WinAppDriverHelper.cs | 1 + src/Legerity.Core/Windows/WindowsAppManagerOptions.cs | 6 +++++- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Legerity.Core/Android/AndroidAppManagerOptions.cs b/src/Legerity.Core/Android/AndroidAppManagerOptions.cs index ba4b206..2488d91 100644 --- a/src/Legerity.Core/Android/AndroidAppManagerOptions.cs +++ b/src/Legerity.Core/Android/AndroidAppManagerOptions.cs @@ -149,11 +149,6 @@ public AndroidAppManagerOptions( /// public string DeviceId { get; set; } - /// - /// Gets or sets a value indicating whether to launch the Appium server instance. - /// - public bool LaunchAppiumServer { get; set; } - /// /// Configures the with the specified additional options. /// diff --git a/src/Legerity.Core/AppManager.cs b/src/Legerity.Core/AppManager.cs index a2cb913..fa942c7 100644 --- a/src/Legerity.Core/AppManager.cs +++ b/src/Legerity.Core/AppManager.cs @@ -223,9 +223,9 @@ private static WebDriver StartAndroidApp(AndroidAppManagerOptions androidOpts) private static WebDriver StartWindowsApp(WindowsAppManagerOptions winOpts) { - if (winOpts.LaunchWinAppDriver) + if (winOpts.LaunchAppiumServer || winOpts.LaunchWinAppDriver) { - WinAppDriverHelper.Run(); + AppiumServerHelper.Run(); } var app = new WindowsDriver( diff --git a/src/Legerity.Core/AppiumManagerOptions.cs b/src/Legerity.Core/AppiumManagerOptions.cs index 2f82221..57cdab5 100644 --- a/src/Legerity.Core/AppiumManagerOptions.cs +++ b/src/Legerity.Core/AppiumManagerOptions.cs @@ -23,6 +23,11 @@ public AppiumOptions AppiumOptions set => DriverOptions = value; } + /// + /// Gets or sets a value indicating whether to launch the Appium server instance. + /// + public bool LaunchAppiumServer { get; set; } + /// /// Configures the with the specified additional options. /// diff --git a/src/Legerity.Core/IOS/IOSAppManagerOptions.cs b/src/Legerity.Core/IOS/IOSAppManagerOptions.cs index 6a49aed..6371e8b 100644 --- a/src/Legerity.Core/IOS/IOSAppManagerOptions.cs +++ b/src/Legerity.Core/IOS/IOSAppManagerOptions.cs @@ -94,11 +94,6 @@ public IOSAppManagerOptions( /// public string AutomationName { get; set; } = "XCUITest"; - /// - /// Gets or sets a value indicating whether to launch the Appium server instance. - /// - public bool LaunchAppiumServer { get; set; } - /// /// Configures the with the specified additional options. /// diff --git a/src/Legerity.Core/Windows/Helpers/WinAppDriverHelper.cs b/src/Legerity.Core/Windows/Helpers/WinAppDriverHelper.cs index 1a2ad74..1ae3bab 100644 --- a/src/Legerity.Core/Windows/Helpers/WinAppDriverHelper.cs +++ b/src/Legerity.Core/Windows/Helpers/WinAppDriverHelper.cs @@ -9,6 +9,7 @@ namespace Legerity.Windows.Helpers; /// /// Defines a helper class for the WinAppDriver. /// +[Obsolete("WinAppDriver is not well maintained and is not supported directly by Appium 5 due to W3C standards. Instead, install the appium-windows-driver for the Appium CLI, and use the AppiumServerHelper to initialize.")] public static class WinAppDriverHelper { /// diff --git a/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs b/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs index b7cad37..f227e53 100644 --- a/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs +++ b/src/Legerity.Core/Windows/WindowsAppManagerOptions.cs @@ -1,3 +1,5 @@ +using System; + namespace Legerity.Windows; using System.Collections.Generic; @@ -49,6 +51,7 @@ public WindowsAppManagerOptions(string appId, params (string, object)[] addition /// /// Gets or sets a value indicating whether to launch the WinAppDriver if it is not already running. /// + [Obsolete("Please use LaunchAppiumServer instead. LaunchWinAppDriver will continue to function, however, the WinAppDriver will not be launched directly due to no direct support by the W3C standard implemented in Appium 5. This property will be removed in a future release.")] public bool LaunchWinAppDriver { get; set; } /// @@ -70,7 +73,8 @@ public WindowsAppManagerOptions(string appId, params (string, object)[] addition public override void Configure() { base.Configure(); - AppiumOptions.AddAdditionalAppiumOption("app", AppId); + AppiumOptions.App = AppId; + AppiumOptions.AutomationName = "Windows"; } ///