diff --git a/src/Appium.Net/Appium.Net.csproj b/src/Appium.Net/Appium.Net.csproj index 67564fe2e..c0ac1a153 100644 --- a/src/Appium.Net/Appium.Net.csproj +++ b/src/Appium.Net/Appium.Net.csproj @@ -8,7 +8,7 @@ Appium-Dotnet-Driver false true - Copyright © 2020 + Copyright © 2021 https://github.com/appium/appium-dotnet-driver https://github.com/appium/appium-dotnet-driver git @@ -26,8 +26,8 @@ LICENSE.txt - - Appium.Net.xml + + Appium.Net.xml Appium.Net.xml @@ -48,9 +48,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + diff --git a/src/Appium.Net/Appium.Net.xml b/src/Appium.Net/Appium.Net.xml index a42393a2b..c56b47ad7 100644 --- a/src/Appium.Net/Appium.Net.xml +++ b/src/Appium.Net/Appium.Net.xml @@ -159,7 +159,7 @@ The image content of the clipboard as base64-encoded string or null if there is no image on the clipboard - + Initializes a new instance of the AndroidElement class. @@ -3348,7 +3348,7 @@ - + Initializes a new instance of the AppiumWebElement class. @@ -4265,7 +4265,7 @@ IWebElement object so that you can interact that object - IWebDriver driver = new RemoteWebDriver(new DriverOptions()); + IWebDriver driver = new WebDriver(new DriverOptions()); IWebElement elem = driver.FindElementByAndroidDataMatcher('elements()')) @@ -4278,7 +4278,7 @@ ReadOnlyCollection of IWebElement object so that you can interact with those objects - IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + IWebDriver driver = new WebDriver(new FirefoxOptions()); ReadOnlyCollection]]> elem = driver.FindElementsByAndroidDataMatcher(elements()) @@ -4291,7 +4291,7 @@ IWebElement object so that you can interact that object - IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + IWebDriver driver = new WebDriver(new FirefoxOptions()); IWebElement elem = driver.FindElementByAndroidUIAutomator('elements()')) @@ -4311,7 +4311,7 @@ ReadOnlyCollection of IWebElement object so that you can interact with those objects - IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + IWebDriver driver = new WebDriver(new FirefoxOptions()); ReadOnlyCollection]]> elem = driver.FindElementsByAndroidUIAutomator(elements()) @@ -5035,7 +5035,7 @@ The image content of the clipboard as an Image object or null if there is no image on the clipboard - + Initializes a new instance of the IOSElement class. @@ -5182,7 +5182,7 @@ An object containing the Appium options. The maximum amount of time to wait for each command. - + Initializes a new instance of the MacElement class. @@ -6230,7 +6230,7 @@ a Tizen UIAutomation selector ReadOnlyCollection of IWebElement objects so that you can interact with those objects - + Initializes a new instance of the TizenElement class. diff --git a/src/Appium.Net/Appium/Android/AndroidDriver.cs b/src/Appium.Net/Appium/Android/AndroidDriver.cs index 01347f43b..ac747f54b 100644 --- a/src/Appium.Net/Appium/Android/AndroidDriver.cs +++ b/src/Appium.Net/Appium/Android/AndroidDriver.cs @@ -16,7 +16,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; using OpenQA.Selenium.Appium.Service; -using OpenQA.Selenium.Remote; using System; using System.Collections.Generic; using System.Drawing; @@ -303,7 +302,7 @@ public IList GetPerformanceDataTypes() => public string EndTestCoverage(string intent, string path) => AndroidCommandExecutionHelper.EndTestCoverage(this, intent, path); - protected override RemoteWebElementFactory CreateElementFactory() => new AndroidElementFactory(this); + protected override WebElementFactory CreateElementFactory() => new AndroidElementFactory(this); public void SetSetting(string setting, object value) => AndroidCommandExecutionHelper.SetSetting(this, setting, value); diff --git a/src/Appium.Net/Appium/Android/AndroidElement.cs b/src/Appium.Net/Appium/Android/AndroidElement.cs index c04e7973c..8fc204fdb 100644 --- a/src/Appium.Net/Appium/Android/AndroidElement.cs +++ b/src/Appium.Net/Appium/Android/AndroidElement.cs @@ -14,7 +14,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Remote; using System.Collections.Generic; namespace OpenQA.Selenium.Appium.Android @@ -26,7 +25,7 @@ public class AndroidElement : AppiumWebElement, IFindByAndroidUIAutomator /// Driver in use. /// ID of the element. - public AndroidElement(RemoteWebDriver parent, string id) + public AndroidElement(WebDriver parent, string id) : base(parent, id) { } diff --git a/src/Appium.Net/Appium/Android/AndroidElementFactory.cs b/src/Appium.Net/Appium/Android/AndroidElementFactory.cs index 6319e790c..e4b4d6a39 100644 --- a/src/Appium.Net/Appium/Android/AndroidElementFactory.cs +++ b/src/Appium.Net/Appium/Android/AndroidElementFactory.cs @@ -1,14 +1,13 @@ -using OpenQA.Selenium.Remote; - + namespace OpenQA.Selenium.Appium.Android { public class AndroidElementFactory : CachedElementFactory { - public AndroidElementFactory(RemoteWebDriver parentDriver) : base(parentDriver) + public AndroidElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected override AndroidElement CreateCachedElement(RemoteWebDriver parentDriver, string elementId) + protected override AndroidElement CreateCachedElement(WebDriver parentDriver, string elementId) { return new AndroidElement(parentDriver, elementId); } diff --git a/src/Appium.Net/Appium/AppiumCapabilities.cs b/src/Appium.Net/Appium/AppiumCapabilities.cs deleted file mode 100644 index d979939c7..000000000 --- a/src/Appium.Net/Appium/AppiumCapabilities.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using System.Reflection; -using OpenQA.Selenium.Remote; - -namespace OpenQA.Selenium.Appium -{ - /// - /// Appium capabilities - /// - public class AppiumCapabilities : DesiredCapabilities - { - /// - /// Get the capabilities back as a dictionary - /// - /// This method uses Reflection and should be removed once - /// AppiumOptions class is avalaible for each driver - /// - /// - public Dictionary ToDictionary() - { - var bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic; - FieldInfo capsField = typeof(DesiredCapabilities) - .GetField("capabilities", bindingFlags); - - return capsField?.GetValue(this) as Dictionary; - } - } -} \ No newline at end of file diff --git a/src/Appium.Net/Appium/AppiumCommand.cs b/src/Appium.Net/Appium/AppiumCommand.cs index 16b271f0b..b9f1212a5 100644 --- a/src/Appium.Net/Appium/AppiumCommand.cs +++ b/src/Appium.Net/Appium/AppiumCommand.cs @@ -12,7 +12,6 @@ //See the License for the specific language governing permissions and //limitations under the License. -using OpenQA.Selenium.Remote; using System.Collections.Generic; namespace OpenQA.Selenium.Appium @@ -26,9 +25,9 @@ public class AppiumCommand { #region Context Commands - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.Contexts, "/session/{sessionId}/contexts"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetContext, "/session/{sessionId}/context"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetContext, "/session/{sessionId}/context"), + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.Contexts, "/session/{sessionId}/contexts"), + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetContext, "/session/{sessionId}/context"), + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetContext, "/session/{sessionId}/context"), #endregion Context Commands @@ -36,121 +35,121 @@ public class AppiumCommand #region Clipboard - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.GetClipboard, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetClipboard, "/session/{sessionId}/appium/device/get_clipboard"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetClipboard, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetClipboard, "/session/{sessionId}/appium/device/set_clipboard"), #endregion #region Device -> Network Commands - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ToggleAirplaneMode, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ToggleAirplaneMode, "/session/{sessionId}/appium/device/toggle_airplane_mode"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ToggleData, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ToggleData, "/session/{sessionId}/appium/device/toggle_data"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ToggleWiFi, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ToggleWiFi, "/session/{sessionId}/appium/device/toggle_wifi"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ToggleLocationServices, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ToggleLocationServices, "/session/{sessionId}/appium/device/toggle_location_services"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.GsmCall, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GsmCall, "/session/{sessionId}/appium/device/gsm_call"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SendSms, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SendSms, "/session/{sessionId}/appium/device/send_sms"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetGsmSignalStrength, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetGsmSignalStrength, "/session/{sessionId}/appium/device/gsm_signal"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetGsmVoiceState, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetGsmVoiceState, "/session/{sessionId}/appium/device/gsm_voice"), #endregion #region Device System Commands - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.OpenNotifications, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.OpenNotifications, "/session/{sessionId}/appium/device/open_notifications"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.SystemTime, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.SystemTime, "/session/{sessionId}/appium/device/system_time"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.SystemBars, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.SystemBars, "/session/{sessionId}/appium/device/system_bars"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetDisplayDensity, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetDisplayDensity, "/session/{sessionId}/appium/device/display_density"), #endregion - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ShakeDevice, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ShakeDevice, "/session/{sessionId}/appium/device/shake"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.LockDevice, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.LockDevice, "/session/{sessionId}/appium/device/lock"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.IsLocked, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.IsLocked, "/session/{sessionId}/appium/device/is_locked"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.UnlockDevice, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.UnlockDevice, "/session/{sessionId}/appium/device/unlock"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.PressKeyCode, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PressKeyCode, "/session/{sessionId}/appium/device/press_keycode"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.LongPressKeyCode, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.LongPressKeyCode, "/session/{sessionId}/appium/device/long_press_keycode"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.Rotate, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.Rotate, "/session/{sessionId}/appium/device/rotate"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetCurrentActivity, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetCurrentActivity, "/session/{sessionId}/appium/device/current_activity"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetCurrentPackage, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetCurrentPackage, "/session/{sessionId}/appium/device/current_package"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.InstallApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.InstallApp, "/session/{sessionId}/appium/device/install_app"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.RemoveApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.RemoveApp, "/session/{sessionId}/appium/device/remove_app"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ActivateApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ActivateApp, "/session/{sessionId}/appium/device/activate_app"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.TerminateApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.TerminateApp, "/session/{sessionId}/appium/device/terminate_app"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.IsAppInstalled, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.IsAppInstalled, "/session/{sessionId}/appium/device/app_installed"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.PushFile, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PushFile, "/session/{sessionId}/appium/device/push_file"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.PullFile, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PullFile, "/session/{sessionId}/appium/device/pull_file"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.PullFolder, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PullFolder, "/session/{sessionId}/appium/device/pull_folder"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.GetPerformanceData, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetPerformanceData, "/session/{sessionId}/appium/getPerformanceData"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.GetPerformanceDataTypes, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetPerformanceDataTypes, "/session/{sessionId}/appium/performanceData/types"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.LaunchApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.LaunchApp, "/session/{sessionId}/appium/app/launch"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.CloseApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.CloseApp, "/session/{sessionId}/appium/app/close"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ResetApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ResetApp, "/session/{sessionId}/appium/app/reset"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.BackgroundApp, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.BackgroundApp, "/session/{sessionId}/appium/app/background"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.EndTestCoverage, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.EndTestCoverage, "/session/{sessionId}/appium/app/end_test_coverage"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.GetAppStrings, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetAppStrings, "/session/{sessionId}/appium/app/strings"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.GetAppState, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetAppState, "/session/{sessionId}/appium/device/app_state"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.HideKeyboard, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.HideKeyboard, "/session/{sessionId}/appium/device/hide_keyboard"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.IsKeyboardShown, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.IsKeyboardShown, "/session/{sessionId}/appium/device/is_keyboard_shown"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.StartActivity, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.StartActivity, "/session/{sessionId}/appium/device/start_activity"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetSettings, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetSettings, "/session/{sessionId}/appium/settings"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.UpdateSettings, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.UpdateSettings, "/session/{sessionId}/appium/settings"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.TouchID, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.TouchID, "/session/{sessionId}/appium/simulator/touch_id"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.FingerPrint, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.FingerPrint, "/session/{sessionId}/appium/device/finger_print"), #endregion Driver Commands #region Touch Commands - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.PerformMultiAction, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PerformMultiAction, "/session/{sessionId}/touch/multi/perform"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.PerformTouchAction, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PerformTouchAction, "/session/{sessionId}/touch/perform"), #endregion Touch Commands @@ -159,60 +158,60 @@ public class AppiumCommand #region W3C Actions - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.Actions, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.Actions, "/session/{sessionId}/actions"), #endregion W3C Actions #region JSON Wire Protocol Commands - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetOrientation, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetOrientation, "/session/{sessionId}/orientation"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetOrientation, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetOrientation, "/session/{sessionId}/orientation"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetConnectionType, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetConnectionType, "/session/{sessionId}/network_connection"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetConnectionType, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetConnectionType, "/session/{sessionId}/network_connection"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetLocation, "/session/{sessionId}/location"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetLocation, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetLocation, "/session/{sessionId}/location"), + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetLocation, "/session/{sessionId}/location"), #region Input Method (IME) - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetAvailableEngines, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetAvailableEngines, "/session/{sessionId}/ime/available_engines"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetActiveEngine, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetActiveEngine, "/session/{sessionId}/ime/active_engine"), - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.IsIMEActive, + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.IsIMEActive, "/session/{sessionId}/ime/activated"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ActivateEngine, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ActivateEngine, "/session/{sessionId}/ime/activate"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.DeactivateEngine, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.DeactivateEngine, "/session/{sessionId}/ime/deactivate"), #endregion Input Method (IME) #region Input value - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.ReplaceValue, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ReplaceValue, "/session/{sessionId}/appium/element/{id}/replace_value"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.SetValue, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.SetValue, "/session/{sessionId}/appium/element/{id}/value"), #endregion Input value #region SeassionData - new AppiumCommand(CommandInfo.GetCommand, AppiumDriverCommand.GetSession, "/session/{sessionId}/"), + new AppiumCommand(HttpCommandInfo.GetCommand, AppiumDriverCommand.GetSession, "/session/{sessionId}/"), #endregion SeassionData #region Recording Screen - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.StartRecordingScreen, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.StartRecordingScreen, "/session/{sessionId}/appium/start_recording_screen"), - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.StopRecordingScreen, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.StopRecordingScreen, "/session/{sessionId}/appium/stop_recording_screen"), #endregion Recording Screen @@ -221,14 +220,14 @@ public class AppiumCommand #region Compare Images - new AppiumCommand(CommandInfo.PostCommand, AppiumDriverCommand.CompareImages, + new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.CompareImages, "/session/{sessionId}/appium/compare_images"), #endregion - new AppiumCommand(CommandInfo.GetCommand, DriverCommand.GetAvailableLogTypes, + new AppiumCommand(HttpCommandInfo.GetCommand, DriverCommand.GetAvailableLogTypes, "session/{sessionId}/log/types"), - new AppiumCommand(CommandInfo.PostCommand, DriverCommand.GetLog, "session/{sessionId}/log") + new AppiumCommand(HttpCommandInfo.PostCommand, DriverCommand.GetLog, "session/{sessionId}/log") }; /// @@ -237,11 +236,11 @@ public class AppiumCommand /// /// is a CommandInfoRepository instance which is used /// The given CommandInfoRepository instance with added Appium-specific commands - internal static CommandInfoRepository Merge(CommandInfoRepository repo) + internal static ICommandExecutor Merge(ICommandExecutor repo) { foreach (AppiumCommand entry in CommandList) { - var commandInfo = new CommandInfo(entry.CommandType, entry.ApiEndpoint); + var commandInfo = new HttpCommandInfo(entry.CommandType, entry.ApiEndpoint); repo.TryAddCommand(entry.CommandName, commandInfo); } diff --git a/src/Appium.Net/Appium/AppiumDriver.cs b/src/Appium.Net/Appium/AppiumDriver.cs index bdcdb5853..a41923d4a 100644 --- a/src/Appium.Net/Appium/AppiumDriver.cs +++ b/src/Appium.Net/Appium/AppiumDriver.cs @@ -18,7 +18,6 @@ using OpenQA.Selenium.Appium.Service; using OpenQA.Selenium.Internal; using OpenQA.Selenium.Interactions; -using OpenQA.Selenium.Remote; using System; using System.Collections; using System.Collections.Generic; @@ -30,8 +29,7 @@ namespace OpenQA.Selenium.Appium { - public abstract class AppiumDriver : RemoteWebDriver, IFindsById, IFindsByClassName, IFindsByName, - IFindsByTagName, IFindsByImage, IExecuteMethod, + public abstract class AppiumDriver : WebDriver, IFindsByImage, IHasSessionDetails, IHasLocation, IFindByAccessibilityId, @@ -48,7 +46,7 @@ public abstract class AppiumDriver : RemoteWebDriver, IFindsById, IFindsByCla public AppiumDriver(ICommandExecutor commandExecutor, ICapabilities appiumOptions) : base(commandExecutor, appiumOptions) { - AppiumCommand.Merge(commandExecutor.CommandInfoRepository); + AppiumCommand.Merge(commandExecutor); ElementFactory = CreateElementFactory(); } @@ -94,94 +92,66 @@ public AppiumDriver(AppiumLocalService service, ICapabilities appiumOptions, Tim #endregion Constructors - #region Overrides to fix "css selector" issue - - IWebElement IFindsByClassName.FindElementByClassName(string className) => - base.FindElement(MobileSelector.ClassName, className); - - ReadOnlyCollection IFindsByClassName.FindElementsByClassName(string className) => - base.FindElements(MobileSelector.ClassName, className); - - IWebElement IFindsById.FindElementById(string id) => - base.FindElement(MobileSelector.Id, id); - - ReadOnlyCollection IFindsById.FindElementsById(string id) => - base.FindElements(MobileSelector.Id, id); - - IWebElement IFindsByName.FindElementByName(string name) => - base.FindElement(MobileSelector.Name, name); - - ReadOnlyCollection IFindsByName.FindElementsByName(string name) => - base.FindElements(MobileSelector.Name, name); - - IWebElement IFindsByTagName.FindElementByTagName(string tagName) => - base.FindElement(MobileSelector.TagName, tagName); - - ReadOnlyCollection IFindsByTagName.FindElementsByTagName(string tagName) => - base.FindElements(MobileSelector.TagName, tagName); - - #endregion Overrides to fix "css selector" issue - #region Generic FindMethods public new W FindElement(By by) => - (W) base.FindElement(by); + (W)base.FindElement(by); public new ReadOnlyCollection FindElements(By by) => ConvertToExtendedWebElementCollection(base.FindElements(by)); - public new W FindElement(string by, string value) => (W) base.FindElement(by, value); + public new W FindElement(string by, string value) => (W)base.FindElement(by, value); public new IReadOnlyCollection FindElements(string selector, string value) => ConvertToExtendedWebElementCollection(base.FindElements(selector, value)); - public new W FindElementByClassName(string className) => - (W) base.FindElement(MobileSelector.ClassName, className); + public W FindElementByClassName(string className) => + (W)base.FindElement(MobileSelector.ClassName, className); - public new ReadOnlyCollection FindElementsByClassName(string className) => + public ReadOnlyCollection FindElementsByClassName(string className) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.ClassName, className)); - public new W FindElementById(string id) => - (W) base.FindElement(MobileSelector.Id, id); + public W FindElementById(string id) => + (W)base.FindElement(MobileSelector.Id, id); - public new ReadOnlyCollection FindElementsById(string id) => + public ReadOnlyCollection FindElementsById(string id) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.Id, id)); - public new W FindElementByCssSelector(string cssSelector) => - (W) base.FindElementByCssSelector(cssSelector); + public W FindElementByCssSelector(string cssSelector) => + (W)base.FindElement("css selector", cssSelector); - public new ReadOnlyCollection FindElementsByCssSelector(string cssSelector) => - ConvertToExtendedWebElementCollection(base.FindElementsByCssSelector(cssSelector)); + public ReadOnlyCollection FindElementsByCssSelector(string cssSelector) => + ConvertToExtendedWebElementCollection(base.FindElements("css selector", cssSelector)); - public new W FindElementByLinkText(string linkText) => - (W) base.FindElementByLinkText(linkText); + public W FindElementByLinkText(string linkText) => + (W)base.FindElement("link text", linkText); - public new ReadOnlyCollection FindElementsByLinkText(string linkText) => - ConvertToExtendedWebElementCollection(base.FindElementsByLinkText(linkText)); + public ReadOnlyCollection FindElementsByLinkText(string linkText) => + ConvertToExtendedWebElementCollection(base.FindElements("link text", linkText)); - public new W FindElementByName(string name) => - (W) base.FindElement(MobileSelector.Name, name); + public W FindElementByName(string name) => + (W)base.FindElement(MobileSelector.Name, name); - public new ReadOnlyCollection FindElementsByName(string name) => + public ReadOnlyCollection FindElementsByName(string name) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.Name, name)); - public new W FindElementByPartialLinkText(string partialLinkText) => - (W) base.FindElementByPartialLinkText(partialLinkText); + public W FindElementByPartialLinkText(string partialLinkText) => + (W)base.FindElement("partial link text", partialLinkText); - public new ReadOnlyCollection FindElementsByPartialLinkText(string partialLinkText) => - ConvertToExtendedWebElementCollection(base.FindElementsByPartialLinkText(partialLinkText)); + public ReadOnlyCollection FindElementsByPartialLinkText(string partialLinkText) => + ConvertToExtendedWebElementCollection(base.FindElements("partial link text", partialLinkText)); - public new W FindElementByTagName(string tagName) => - (W) base.FindElement(MobileSelector.TagName, tagName); + public W FindElementByTagName(string tagName) => + (W)base.FindElement(MobileSelector.TagName, tagName); - public new ReadOnlyCollection FindElementsByTagName(string tagName) => + public ReadOnlyCollection FindElementsByTagName(string tagName) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.TagName, tagName)); - public new W FindElementByXPath(string xpath) => - (W) base.FindElementByXPath(xpath); + public W FindElementByXPath(string xpath) => + (W)base.FindElement("xpath", xpath); - public new ReadOnlyCollection FindElementsByXPath(string xpath) => - ConvertToExtendedWebElementCollection(base.FindElementsByXPath(xpath)); + public ReadOnlyCollection FindElementsByXPath(string xpath) => + ConvertToExtendedWebElementCollection(base.FindElements("xpath", xpath)); #region IFindByAccessibilityId Members @@ -248,7 +218,7 @@ public bool TerminateApp(string appId) => public bool TerminateApp(string appId, TimeSpan timeout) => Convert.ToBoolean(Execute(AppiumDriverCommand.TerminateApp, - AppiumCommandExecutionHelper.PrepareArguments(new string[] {"appId", "options"}, + AppiumCommandExecutionHelper.PrepareArguments(new string[] { "appId", "options" }, new object[] {appId, new Dictionary() {{"timeout", (long) timeout.TotalMilliseconds}}})) .Value.ToString()); @@ -274,11 +244,11 @@ public void PushFile(string pathOnDevice, byte[] base64Data) => public void PushFile(string pathOnDevice, FileInfo file) => AppiumCommandExecutionHelper.PushFile(this, pathOnDevice, file); - public void LaunchApp() => ((IExecuteMethod) this).Execute(AppiumDriverCommand.LaunchApp); + public void LaunchApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.LaunchApp); - public void CloseApp() => ((IExecuteMethod) this).Execute(AppiumDriverCommand.CloseApp); + public void CloseApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.CloseApp); - public void ResetApp() => ((IExecuteMethod) this).Execute(AppiumDriverCommand.ResetApp); + public void ResetApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.ResetApp); public void FingerPrint(int fingerprintId) => AppiumCommandExecutionHelper.FingerPrint(this, fingerprintId); @@ -298,7 +268,7 @@ public void BackgroundApp(TimeSpan timeSpan) => AppiumCommandExecutionHelper.PrepareArgument("seconds", timeSpan.TotalSeconds)); public AppState GetAppState(string appId) => - (AppState) Convert.ToInt32(Execute(AppiumDriverCommand.GetAppState, + (AppState)Convert.ToInt32(Execute(AppiumDriverCommand.GetAppState, AppiumCommandExecutionHelper.PrepareArgument("appId", appId)).Value.ToString()); /// @@ -326,7 +296,7 @@ public Dictionary GetAppStringDictionary(string language = null, parameters = null; } - return (Dictionary) Execute(AppiumDriverCommand.GetAppStrings, parameters).Value; + return (Dictionary)Execute(AppiumDriverCommand.GetAppStrings, parameters).Value; } /// @@ -364,7 +334,7 @@ public Location Location { get { - var commandResponse = ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetLocation); + var commandResponse = ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetLocation); var locationValues = commandResponse.Value as Dictionary; return new Location { @@ -388,7 +358,7 @@ public virtual string Context { get { - var commandResponse = ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetContext); + var commandResponse = ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetContext); return commandResponse.Value as string; } set @@ -402,7 +372,7 @@ public virtual ReadOnlyCollection Contexts { get { - var commandResponse = ((IExecuteMethod) this).Execute(AppiumDriverCommand.Contexts); + var commandResponse = ((IExecuteMethod)this).Execute(AppiumDriverCommand.Contexts); var contexts = new List(); var objects = commandResponse.Value as object[]; @@ -423,7 +393,7 @@ public ScreenOrientation Orientation { get { - var commandResponse = ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetOrientation); + var commandResponse = ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetOrientation); return (commandResponse.Value as string).ConvertToScreenOrientation(); } set @@ -445,7 +415,7 @@ public ScreenOrientation Orientation public List GetIMEAvailableEngines() { var retVal = new List(); - var commandResponse = ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetAvailableEngines); + var commandResponse = ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetAvailableEngines); var objectArr = commandResponse.Value as object[]; if (null != objectArr) { @@ -460,14 +430,14 @@ public List GetIMEAvailableEngines() /// /// Active IME Engine public string GetIMEActiveEngine() => - ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetActiveEngine).Value as string; + ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetActiveEngine).Value as string; /// /// Is the IME active on the device (NOTE: on Android, this is always true) /// /// true if IME is active, false otherwise public bool IsIMEActive() => - (bool) (((IExecuteMethod) this).Execute(AppiumDriverCommand.IsIMEActive).Value); + (bool)(((IExecuteMethod)this).Execute(AppiumDriverCommand.IsIMEActive).Value); /// /// Activate the given IME on Device @@ -481,7 +451,7 @@ public void ActivateIMEEngine(string imeEngine) => /// Deactivate the currently Active IME Engine on device /// public void DeactiveIMEEngine() => - ((IExecuteMethod) this).Execute(AppiumDriverCommand.DeactivateEngine); + ((IExecuteMethod)this).Execute(AppiumDriverCommand.DeactivateEngine); #endregion Input Method (IME) @@ -533,7 +503,7 @@ public void PerformTouchAction(ITouchAction touchAction) /// Gets device date and time for both iOS(Supports only real device) and Android devices /// /// A string which consists of date and time - public string DeviceTime => ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetDeviceTime).Value.ToString(); + public string DeviceTime => ((IExecuteMethod)this).Execute(AppiumDriverCommand.GetDeviceTime).Value.ToString(); #endregion Device Time @@ -544,7 +514,7 @@ public IDictionary SessionDetails get { var session = - (IDictionary) ((IExecuteMethod) this).Execute(AppiumDriverCommand.GetSession) + (IDictionary)((IExecuteMethod)this).Execute(AppiumDriverCommand.GetSession) .Value; return new ReadOnlyDictionary(session.Where(entry => { @@ -575,7 +545,7 @@ public object GetSessionDetail(string detail) #region Recording Screen public string StartRecordingScreen() => - ((IExecuteMethod) this).Execute(AppiumDriverCommand.StartRecordingScreen).Value.ToString(); + ((IExecuteMethod)this).Execute(AppiumDriverCommand.StartRecordingScreen).Value.ToString(); public string StartRecordingScreen(IScreenRecordingOptions options) { @@ -584,7 +554,7 @@ public string StartRecordingScreen(IScreenRecordingOptions options) } public string StopRecordingScreen() => - ((IExecuteMethod) this).Execute(AppiumDriverCommand.StopRecordingScreen).Value.ToString(); + ((IExecuteMethod)this).Execute(AppiumDriverCommand.StopRecordingScreen).Value.ToString(); public string StopRecordingScreen(IScreenRecordingOptions options) { @@ -688,11 +658,11 @@ public SimilarityMatchingResult GetImagesSimilarity(string base64Image1, string #region Support methods - protected abstract RemoteWebElementFactory CreateElementFactory(); + protected new abstract WebElementFactory CreateElementFactory(); internal static ICapabilities SetPlatformToCapabilities(DriverOptions dc, string desiredPlatform) { - dc.AddAdditionalCapability(MobileCapabilityType.PlatformName, desiredPlatform); + dc.PlatformName = desiredPlatform; return dc.ToCapabilities(); } diff --git a/src/Appium.Net/Appium/AppiumOptions.cs b/src/Appium.Net/Appium/AppiumOptions.cs index 432819a1a..bc9def95b 100644 --- a/src/Appium.Net/Appium/AppiumOptions.cs +++ b/src/Appium.Net/Appium/AppiumOptions.cs @@ -1,4 +1,5 @@ -using System; +using OpenQA.Selenium.Remote; +using System; using System.Collections.Generic; namespace OpenQA.Selenium.Appium @@ -8,38 +9,146 @@ namespace OpenQA.Selenium.Appium /// public class AppiumOptions : DriverOptions { + private const string VendorPrefix = "appium"; + private const string AutomationNameOption = "appium:automationName"; + private const string DeviceNameOption = "appium:deviceName"; + private const string AppOption = "appium:app"; + private const string PlatformVersionOption = "appium:platformVersion"; + + private readonly Dictionary additionalAppiumOptions = new Dictionary(); + + + /// + /// Initializes a new instance of the class. + /// + public AppiumOptions() : base() + { + this.AddKnownCapabilityName(AppiumOptions.AutomationNameOption, "AutomationName property"); + this.AddKnownCapabilityName(AppiumOptions.DeviceNameOption, "DeviceName property"); + this.AddKnownCapabilityName(AppiumOptions.AppOption, "Application property"); + this.AddKnownCapabilityName(AppiumOptions.PlatformVersionOption, "PlatformVersion property"); + this.AddKnownCapabilityName("app", "Application property"); + } + + /// + /// Gets or sets the AutoamtionName of the Appium browser's (e.g. Appium, Selendroid and so on) setting. + /// + public string AutomationName { get; set; } + + + /// + /// Gets or sets the DeviceName of the Appium browser's (e.g. Pixel 3XL, Galaxy S20 and so on) setting. + /// + public string DeviceName { get; set; } + + /// + /// Gets or sets the Capability name used for the apllication setting. + /// + public string App { get; set; } + + /// + /// Gets or sets the PlatformVersion of the Appium browser's (e.g. 10, 11 and so on) setting. + /// + public string PlatformVersion { get; set; } + /// - /// The dictionary of capabilities + /// Provides a means to add additional capabilities not yet added as type safe options + /// for the Appium driver. /// - private readonly AppiumCapabilities capabilities = new AppiumCapabilities(); + /// The name of the capability to add. + /// The value of the capability to add. + /// + /// thrown when attempting to add a capability for which there is already a type safe option, or + /// when is or the empty string. + /// + /// Calling + /// where has already been added will overwrite the + /// existing value with the new value in . + /// Calling this method adds capabilities to the Appium-specific options object passed to + /// webdriver executable. + public void AddAdditionalAppiumOption(string optionName, object optionValue) + { + string name = optionName.Contains(":") ? optionName : $"{VendorPrefix}:{optionName}"; + this.ValidateCapabilityName(name); + this.additionalAppiumOptions[name] = optionValue; + } /// /// Add new capabilities /// /// Capability name /// Capabilities value, which cannot be null or empty + [Obsolete("Use the the AddAdditionalAppiumOption method for adding additional options")] public override void AddAdditionalCapability(string capabilityName, object capabilityValue) { - if (string.IsNullOrEmpty(capabilityName)) - { - throw new ArgumentException("Capability name may not be null an empty string.", "capabilityName"); - } + this.AddAdditionalAppiumOption(capabilityName, capabilityValue); + } - this.capabilities[capabilityName] = capabilityValue; + public override void AddAdditionalOption(string optionName, object optionValue) + { + throw new NotImplementedException("Use the the AddAdditionalAppiumOption method for adding additional options"); } - /// + /// /// A desired capability public override ICapabilities ToCapabilities() { - return this.capabilities; + var capabilities = this.GenerateDesiredCapabilities(true); + + foreach (var option in this.BuildAppiumOptionsDictionary()) + { + capabilities.SetCapability(option.Key, option.Value); + } + + return capabilities; + } + + protected virtual Dictionary BuildAppiumKnownOptionsDictionary() + { + Dictionary knownOptions = new Dictionary(); + + if (!string.IsNullOrEmpty(this.App)) + { + knownOptions[AppOption] = this.App; + } + + if (!string.IsNullOrEmpty(this.AutomationName)) + { + knownOptions[AutomationNameOption] = this.AutomationName; + } + + if (!string.IsNullOrEmpty(this.DeviceName)) + { + knownOptions[DeviceNameOption] = this.DeviceName; + } + + if (!string.IsNullOrEmpty(this.PlatformVersion)) + { + knownOptions[PlatformVersionOption] = this.PlatformVersion; + } + + return knownOptions; + + } + + private Dictionary BuildAppiumOptionsDictionary() + { + var appiumOptions = BuildAppiumKnownOptionsDictionary(); + + foreach (KeyValuePair pair in this.additionalAppiumOptions) + { + appiumOptions.Add(pair.Key, pair.Value); + } + + return appiumOptions; } - public Dictionary ToDictionary() + public IDictionary ToDictionary() { - return this.capabilities.ToDictionary(); + var writeable = this.GenerateDesiredCapabilities(true); + return (writeable.AsReadOnly() as ReadOnlyDesiredCapabilities).ToDictionary(); } } } \ No newline at end of file diff --git a/src/Appium.Net/Appium/AppiumWebElement.cs b/src/Appium.Net/Appium/AppiumWebElement.cs index f2fa2b485..bef38473f 100644 --- a/src/Appium.Net/Appium/AppiumWebElement.cs +++ b/src/Appium.Net/Appium/AppiumWebElement.cs @@ -14,13 +14,13 @@ using OpenQA.Selenium.Appium.Interfaces; using OpenQA.Selenium.Internal; -using OpenQA.Selenium.Remote; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections; using OpenQA.Selenium.Appium.Enums; using System; using System.Drawing; +using Appium.Interfaces.Generic.SearchContext; namespace OpenQA.Selenium.Appium { @@ -40,16 +40,16 @@ namespace OpenQA.Selenium.Appium /// } /// /// - public abstract class AppiumWebElement : RemoteWebElement, - IMobileElement, IWebElementCached, - IFindsById, IFindsByClassName, IFindsByName, IFindsByTagName + public abstract class AppiumWebElement : WebElement, + IMobileElement, IWebElementCached, + IFindsById, IFindsByClassName, IFindsByName, IFindsByTagName { /// /// Initializes a new instance of the AppiumWebElement class. /// /// Driver in use. /// ID of the element. - public AppiumWebElement(RemoteWebDriver parent, string id) + public AppiumWebElement(WebDriver parent, string id) : base(parent, id) { } @@ -80,7 +80,7 @@ public virtual void DisableCache() public override string Text => CacheValue("text", () => base.Text)?.ToString(); - public override bool Displayed => Convert.ToBoolean(CacheValue("displayed", () => Execute(DriverCommand.IsElementDisplayed, new Dictionary{{"id", Id}}).Value)); + public override bool Displayed => Convert.ToBoolean(CacheValue("displayed", () => Execute(DriverCommand.IsElementDisplayed, new Dictionary { { "id", Id } }).Value)); public override bool Enabled => Convert.ToBoolean(CacheValue("enabled", () => base.Enabled)); @@ -203,8 +203,6 @@ public void Rotate(Dictionary opts) #endregion - - #region FindMethods #region Overrides to fix "css selector" issue @@ -215,7 +213,7 @@ IWebElement IFindsByClassName.FindElementByClassName(string className) => ReadOnlyCollection IFindsByClassName.FindElementsByClassName(string className) => base.FindElements(MobileSelector.ClassName, className); - IWebElement IFindsById.FindElementById(string id) => + IWebElement IFindsById.FindElementById(string id) => base.FindElement(MobileSelector.Id, id); ReadOnlyCollection IFindsById.FindElementsById(string id) => @@ -235,6 +233,7 @@ ReadOnlyCollection IFindsByTagName.FindElementsByTagName(string tag #endregion Overrides to fix "css selector" issue + #region IFindByAccessibilityId Members public AppiumWebElement FindElementByAccessibilityId(string selector) => @@ -250,7 +249,7 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin /// /// Mechanism to find element /// first element found - public new AppiumWebElement FindElement(By by) => (AppiumWebElement) base.FindElement(by); + public new AppiumWebElement FindElement(By by) => (AppiumWebElement)base.FindElement(by); /// /// Find the elements on the page by using the object and returns a ReadonlyCollection of the Elements on the page @@ -261,7 +260,7 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin ConvertToExtendedWebElementCollection(base.FindElements(by)); public new AppiumWebElement FindElement(string by, string value) => - (AppiumWebElement) base.FindElement(by, value); + (AppiumWebElement)base.FindElement(by, value); public new IReadOnlyCollection FindElements(string selector, string value) => ConvertToExtendedWebElementCollection(base.FindElements(selector, value)); @@ -271,15 +270,15 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin /// /// CSS class name on the element /// first element found - (AppiumWebElement) base.FindElement(MobileSelector.ClassName, className); + public AppiumWebElement FindElementByClassName(string className) => + (AppiumWebElement)base.FindElement(MobileSelector.ClassName, className); /// /// Finds a list of elements that match the class name supplied /// /// CSS class name on the element /// ReadOnlyCollection of elements found FindElementsByClassName(string className) => + public ReadOnlyCollection FindElementsByClassName(string className) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.ClassName, className)); /// @@ -287,15 +286,15 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin /// /// ID of the element /// First element found - public new AppiumWebElement FindElementById(string id) => - (AppiumWebElement) base.FindElement(MobileSelector.Id, id); + public AppiumWebElement FindElementById(string id) => + (AppiumWebElement)base.FindElement(MobileSelector.Id, id); /// /// Finds a list of elements that match the ID supplied /// /// ID of the element /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsById(string id) => + public ReadOnlyCollection FindElementsById(string id) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.Id, id)); /// @@ -303,47 +302,47 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin /// /// The CSS selector to match /// First element found - public new AppiumWebElement FindElementByCssSelector(string cssSelector) => - (AppiumWebElement) base.FindElementByCssSelector(cssSelector); + public AppiumWebElement FindElementByCssSelector(string cssSelector) => + (AppiumWebElement)base.FindElement(By.CssSelector(cssSelector)); /// /// Finds a list of elements that match the CSS selector /// /// The CSS selector to match /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsByCssSelector(string cssSelector) => - ConvertToExtendedWebElementCollection(base.FindElementsByCssSelector(cssSelector)); + public ReadOnlyCollection FindElementsByCssSelector(string cssSelector) => + ConvertToExtendedWebElementCollection(base.FindElements(By.CssSelector(cssSelector))); /// /// Finds the first of elements that match the link text supplied /// /// Link text of element /// First element found - public new AppiumWebElement FindElementByLinkText(string linkText) => - (AppiumWebElement) base.FindElementByLinkText(linkText); + public AppiumWebElement FindElementByLinkText(string linkText) => + (AppiumWebElement)base.FindElement(By.LinkText(linkText)); /// /// Finds a list of elements that match the link text supplied /// /// Link text of element /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsByLinkText(string linkText) => - ConvertToExtendedWebElementCollection(base.FindElementsByLinkText(linkText)); + public ReadOnlyCollection FindElementsByLinkText(string linkText) => + ConvertToExtendedWebElementCollection(base.FindElements(By.LinkText(linkText))); /// /// Finds the first of elements that match the name supplied /// /// Name of the element on the page /// First element found - public new AppiumWebElement FindElementByName(string name) => - (AppiumWebElement) base.FindElement(MobileSelector.Name, name); + public AppiumWebElement FindElementByName(string name) => + (AppiumWebElement)base.FindElement(MobileSelector.Name, name); /// /// Finds a list of elements that match the name supplied /// /// Name of the element on the page /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsByName(string name) => + public ReadOnlyCollection FindElementsByName(string name) => ConvertToExtendedWebElementCollection(base.FindElements(MobileSelector.Name, name)); /// @@ -351,31 +350,31 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin /// /// Part of the link text /// First element found - public new AppiumWebElement FindElementByPartialLinkText(string partialLinkText) => - (AppiumWebElement) base.FindElementByPartialLinkText(partialLinkText); + public AppiumWebElement FindElementByPartialLinkText(string partialLinkText) => + (AppiumWebElement)base.FindElement(By.PartialLinkText(partialLinkText)); /// /// Finds a list of elements that match the part of the link text supplied /// /// Part of the link text /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsByPartialLinkText(string partialLinkText) => - ConvertToExtendedWebElementCollection(base.FindElementsByPartialLinkText(partialLinkText)); + public ReadOnlyCollection FindElementsByPartialLinkText(string partialLinkText) => + ConvertToExtendedWebElementCollection(base.FindElements(By.PartialLinkText(partialLinkText))); /// /// Finds the first of elements that match the DOM Tag supplied /// /// DOM tag name of the element being searched /// First element found - public new AppiumWebElement FindElementByTagName(string tagName) => - (AppiumWebElement) base.FindElement(MobileSelector.TagName, tagName); + public AppiumWebElement FindElementByTagName(string tagName) => + (AppiumWebElement)base.FindElement(MobileSelector.TagName, tagName); /// /// Finds a list of elements that match the DOM Tag supplied /// /// DOM tag name of the element being searched /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsByTagName(string tagName) => + public ReadOnlyCollection FindElementsByTagName(string tagName) => ConvertToExtendedWebElementCollection(FindElements(MobileSelector.TagName, tagName)); /// @@ -383,28 +382,28 @@ public IReadOnlyCollection FindElementsByAccessibilityId(strin /// /// xpath to the element /// First element found - public new AppiumWebElement FindElementByXPath(string xpath) => - (AppiumWebElement) base.FindElementByXPath(xpath); + public AppiumWebElement FindElementByXPath(string xpath) => + (AppiumWebElement)base.FindElement(By.XPath(xpath)); /// /// Finds a list of elements that match the XPath supplied /// /// xpath to the element /// ReadOnlyCollection of elements found - public new ReadOnlyCollection FindElementsByXPath(string xpath) => - ConvertToExtendedWebElementCollection(base.FindElementsByXPath(xpath)); + public ReadOnlyCollection FindElementsByXPath(string xpath) => + ConvertToExtendedWebElementCollection(base.FindElements(By.XPath(xpath))); #endregion public void SetImmediateValue(string value) => Execute(AppiumDriverCommand.SetValue, - new Dictionary() {["id"] = Id, ["value"] = value}); + new Dictionary() { ["id"] = Id, ["value"] = value }); private ReadOnlyCollection ConvertToExtendedWebElementCollection(IEnumerable list) { List result = new List(); foreach (var element in list) { - result.Add((AppiumWebElement) element); + result.Add((AppiumWebElement)element); } return result.AsReadOnly(); } diff --git a/src/Appium.Net/Appium/CachedElementFactory.cs b/src/Appium.Net/Appium/CachedElementFactory.cs index 6ed463808..5eba952ab 100644 --- a/src/Appium.Net/Appium/CachedElementFactory.cs +++ b/src/Appium.Net/Appium/CachedElementFactory.cs @@ -1,17 +1,16 @@ using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Remote; using System; using System.Collections.Generic; namespace OpenQA.Selenium.Appium { - public abstract class CachedElementFactory : RemoteWebElementFactory where T : RemoteWebElement, IWebElementCached + public abstract class CachedElementFactory : WebElementFactory where T : WebElement, IWebElementCached { - public CachedElementFactory(RemoteWebDriver parentDriver) : base(parentDriver) + public CachedElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected abstract T CreateCachedElement(RemoteWebDriver parentDriver, string elementId); + protected abstract T CreateCachedElement(WebDriver parentDriver, string elementId); public virtual bool CacheElementAttributes { @@ -22,7 +21,7 @@ public virtual bool CacheElementAttributes } } - public override RemoteWebElement CreateElement(Dictionary elementDictionary) + public override WebElement CreateElement(Dictionary elementDictionary) { string elementId = GetElementId(elementDictionary); T cachedElement = CreateCachedElement(ParentDriver, elementId); diff --git a/src/Appium.Net/Appium/Interfaces/IExecuteMethod.cs b/src/Appium.Net/Appium/Interfaces/IExecuteMethod.cs index ea6a5ccbb..c13e35b66 100644 --- a/src/Appium.Net/Appium/Interfaces/IExecuteMethod.cs +++ b/src/Appium.Net/Appium/Interfaces/IExecuteMethod.cs @@ -12,7 +12,6 @@ //See the License for the specific language governing permissions and //limitations under the License. -using OpenQA.Selenium.Remote; using System.Collections.Generic; namespace OpenQA.Selenium.Appium.Interfaces diff --git a/src/Appium.Net/Appium/Interfaces/IFindByAndroidDataMatcher.cs b/src/Appium.Net/Appium/Interfaces/IFindByAndroidDataMatcher.cs index 8a66b98bc..bda8ee662 100644 --- a/src/Appium.Net/Appium/Interfaces/IFindByAndroidDataMatcher.cs +++ b/src/Appium.Net/Appium/Interfaces/IFindByAndroidDataMatcher.cs @@ -25,7 +25,7 @@ public interface IFindByAndroidDataMatcher : IFindsByFluentSelector wh /// IWebElement object so that you can interact that object /// /// - /// IWebDriver driver = new RemoteWebDriver(new DriverOptions()); + /// IWebDriver driver = new WebDriver(new DriverOptions()); /// IWebElement elem = driver.FindElementByAndroidDataMatcher('elements()')) /// /// @@ -38,7 +38,7 @@ public interface IFindByAndroidDataMatcher : IFindsByFluentSelector wh /// ReadOnlyCollection of IWebElement object so that you can interact with those objects /// /// - /// IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + /// IWebDriver driver = new WebDriver(new FirefoxOptions()); /// ReadOnlyCollection]]> elem = driver.FindElementsByAndroidDataMatcher(elements()) /// /// diff --git a/src/Appium.Net/Appium/Interfaces/IFindByAndroidUIAutomator.cs b/src/Appium.Net/Appium/Interfaces/IFindByAndroidUIAutomator.cs index 6e4eb0b2d..1d8cbf411 100644 --- a/src/Appium.Net/Appium/Interfaces/IFindByAndroidUIAutomator.cs +++ b/src/Appium.Net/Appium/Interfaces/IFindByAndroidUIAutomator.cs @@ -25,7 +25,7 @@ public interface IFindByAndroidUIAutomator : IFindsByFluentSelector wh /// IWebElement object so that you can interact that object /// /// - /// IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + /// IWebDriver driver = new WebDriver(new FirefoxOptions()); /// IWebElement elem = driver.FindElementByAndroidUIAutomator('elements()')) /// /// @@ -46,7 +46,7 @@ public interface IFindByAndroidUIAutomator : IFindsByFluentSelector wh /// ReadOnlyCollection of IWebElement object so that you can interact with those objects /// /// - /// IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + /// IWebDriver driver = new WebDriver(new FirefoxOptions()); /// ReadOnlyCollection]]> elem = driver.FindElementsByAndroidUIAutomator(elements()) /// /// diff --git a/src/Appium.Net/Appium/Interfaces/IFindByAndroidViewMatcher.cs b/src/Appium.Net/Appium/Interfaces/IFindByAndroidViewMatcher.cs index a32b9b5d1..7cdfd17a0 100644 --- a/src/Appium.Net/Appium/Interfaces/IFindByAndroidViewMatcher.cs +++ b/src/Appium.Net/Appium/Interfaces/IFindByAndroidViewMatcher.cs @@ -25,7 +25,7 @@ public interface IFindByAndroidViewMatcher : IFindsByFluentSelector wh /// IWebElement object so that you can interact that object /// /// - /// IWebDriver driver = new RemoteWebDriver(new DriverOptions()); + /// IWebDriver driver = new WebDriver(new DriverOptions()); /// IWebElement elem = driver.FindElementByAndroidViewMatcher('elements()')) /// /// @@ -38,7 +38,7 @@ public interface IFindByAndroidViewMatcher : IFindsByFluentSelector wh /// ReadOnlyCollection of IWebElement object so that you can interact with those objects /// /// - /// IWebDriver driver = new RemoteWebDriver(new FirefoxOptions()); + /// IWebDriver driver = new WebDriver(new FirefoxOptions()); /// ReadOnlyCollection]]> elem = driver.FindElementsByAndroidViewMatcher(elements()) /// /// diff --git a/src/Appium.Net/Appium/Mac/MacDriver.cs b/src/Appium.Net/Appium/Mac/MacDriver.cs index c56d64b7b..da8aa6d69 100644 --- a/src/Appium.Net/Appium/Mac/MacDriver.cs +++ b/src/Appium.Net/Appium/Mac/MacDriver.cs @@ -14,7 +14,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Service; -using OpenQA.Selenium.Remote; using System; namespace OpenQA.Selenium.Appium.Mac @@ -116,6 +115,6 @@ public MacDriver(AppiumLocalService service, AppiumOptions AppiumOptions, TimeSp } - protected override RemoteWebElementFactory CreateElementFactory() => new MacElementFactory(this); + protected override WebElementFactory CreateElementFactory() => new MacElementFactory(this as WebDriver); } } diff --git a/src/Appium.Net/Appium/Mac/MacElement.cs b/src/Appium.Net/Appium/Mac/MacElement.cs index 9474b2202..678ce8583 100644 --- a/src/Appium.Net/Appium/Mac/MacElement.cs +++ b/src/Appium.Net/Appium/Mac/MacElement.cs @@ -12,8 +12,6 @@ //See the License for the specific language governing permissions and //limitations under the License. -using OpenQA.Selenium.Remote; - namespace OpenQA.Selenium.Appium.Mac { public class MacElement : AppiumWebElement @@ -23,7 +21,7 @@ public class MacElement : AppiumWebElement /// /// Driver in use. /// ID of the element. - public MacElement(RemoteWebDriver parent, string id) + public MacElement(WebDriver parent, string id) : base(parent, id) { } diff --git a/src/Appium.Net/Appium/Mac/MacElementFactory.cs b/src/Appium.Net/Appium/Mac/MacElementFactory.cs index 454e8f474..70cdc2ce4 100644 --- a/src/Appium.Net/Appium/Mac/MacElementFactory.cs +++ b/src/Appium.Net/Appium/Mac/MacElementFactory.cs @@ -1,14 +1,13 @@ -using OpenQA.Selenium.Remote; - + namespace OpenQA.Selenium.Appium.Mac { public class MacElementFactory : CachedElementFactory { - public MacElementFactory(RemoteWebDriver parentDriver) : base(parentDriver) + public MacElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected override MacElement CreateCachedElement(RemoteWebDriver parentDriver, string elementId) + protected override MacElement CreateCachedElement(WebDriver parentDriver, string elementId) { return new MacElement(parentDriver, elementId); } diff --git a/src/Appium.Net/Appium/MultiAction/TouchAction.cs b/src/Appium.Net/Appium/MultiAction/TouchAction.cs index e0479107e..d24bf7b5a 100644 --- a/src/Appium.Net/Appium/MultiAction/TouchAction.cs +++ b/src/Appium.Net/Appium/MultiAction/TouchAction.cs @@ -15,8 +15,6 @@ using OpenQA.Selenium.Appium.Interfaces; using System.Collections.Generic; using System.Reflection; -using OpenQA.Selenium.Remote; -using OpenQA.Selenium.Internal; namespace OpenQA.Selenium.Appium.MultiTouch { @@ -28,9 +26,9 @@ internal class Step private string GetIdForElement(IWebElement el) { - RemoteWebElement remoteWebElement = el as RemoteWebElement; - if (remoteWebElement != null) - return (string) typeof(OpenQA.Selenium.Remote.RemoteWebElement).GetProperty("Id", + WebElement WebElement = el as WebElement; + if (WebElement != null) + return (string) typeof(OpenQA.Selenium.WebElement).GetProperty("Id", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(el, null); diff --git a/src/Appium.Net/Appium/PageObjects/AppiumPageObjectMemberDecorator.cs b/src/Appium.Net/Appium/PageObjects/AppiumPageObjectMemberDecorator.cs index f656dcd63..433735848 100644 --- a/src/Appium.Net/Appium/PageObjects/AppiumPageObjectMemberDecorator.cs +++ b/src/Appium.Net/Appium/PageObjects/AppiumPageObjectMemberDecorator.cs @@ -18,8 +18,6 @@ using OpenQA.Selenium.Appium.iOS; using OpenQA.Selenium.Appium.PageObjects.Interceptors; using OpenQA.Selenium.Appium.PageObjects.Attributes; -using OpenQA.Selenium.Internal; -using OpenQA.Selenium.Remote; using SeleniumExtras.PageObjects; using System; using System.Collections.Generic; @@ -44,7 +42,7 @@ internal static List ListOfAvailableElementTypes { listAvailableElementTypes = new List(); listAvailableElementTypes.Add(typeof(IWebElement)); - listAvailableElementTypes.Add(typeof(RemoteWebElement)); + listAvailableElementTypes.Add(typeof(WebElement)); listAvailableElementTypes.Add(typeof(AppiumWebElement)); listAvailableElementTypes.Add(typeof(AndroidElement)); listAvailableElementTypes.Add(typeof(IOSElement)); diff --git a/src/Appium.Net/Appium/PageObjects/ByFactory.cs b/src/Appium.Net/Appium/PageObjects/ByFactory.cs index f524cada6..e6e2a2299 100644 --- a/src/Appium.Net/Appium/PageObjects/ByFactory.cs +++ b/src/Appium.Net/Appium/PageObjects/ByFactory.cs @@ -18,7 +18,6 @@ using OpenQA.Selenium.Appium.PageObjects.Attributes; using OpenQA.Selenium.Appium.PageObjects.Attributes.Abstract; using OpenQA.Selenium.Appium.Windows; -using OpenQA.Selenium.Remote; using SeleniumExtras.PageObjects; using System; using System.Collections.Generic; diff --git a/src/Appium.Net/Appium/PageObjects/WebDriverUnpackUtility.cs b/src/Appium.Net/Appium/PageObjects/WebDriverUnpackUtility.cs index 37fccd1e1..6190d6935 100644 --- a/src/Appium.Net/Appium/PageObjects/WebDriverUnpackUtility.cs +++ b/src/Appium.Net/Appium/PageObjects/WebDriverUnpackUtility.cs @@ -30,7 +30,7 @@ internal static IWebDriver UnpackWebdriver(ISearchContext context) // Search context it is not only Webdriver. Webelement is search context // too. - // RemoteWebElement and AppiumWebElement implement IWrapsDriver + // WebElement and AppiumWebElement implement IWrapsDriver if ((context as IWrapsDriver) != null) return UnpackWebdriver(((IWrapsDriver) context) .WrappedDriver); diff --git a/src/Appium.Net/Appium/Service/AppiumCommandExecutor.cs b/src/Appium.Net/Appium/Service/AppiumCommandExecutor.cs index d148379ca..220beec57 100644 --- a/src/Appium.Net/Appium/Service/AppiumCommandExecutor.cs +++ b/src/Appium.Net/Appium/Service/AppiumCommandExecutor.cs @@ -14,54 +14,38 @@ using OpenQA.Selenium.Remote; using System; -using System.Reflection; namespace OpenQA.Selenium.Appium.Service { internal class AppiumCommandExecutor : ICommandExecutor { private readonly AppiumLocalService Service; - private readonly Uri URL; private ICommandExecutor RealExecutor; private bool isDisposed; private const string IdempotencyHeader = "X-Idempotency-Key"; private static ICommandExecutor CreateRealExecutor(Uri remoteAddress, TimeSpan commandTimeout) { - var seleniumAssembly = Assembly.Load("WebDriver"); - var commandType = seleniumAssembly.GetType("OpenQA.Selenium.Remote.HttpCommandExecutor"); - ICommandExecutor commandExecutor = null; - - if (null != commandType) - { - commandExecutor = - Activator.CreateInstance(commandType, new object[] { remoteAddress, commandTimeout }) as - ICommandExecutor; - } - - return commandExecutor; + return new HttpCommandExecutor(remoteAddress, commandTimeout); } - private AppiumCommandExecutor(Uri url, ICommandExecutor realExecutor) + private AppiumCommandExecutor(ICommandExecutor realExecutor) { - URL = url; RealExecutor = realExecutor; } internal AppiumCommandExecutor(Uri url, TimeSpan timeForTheServerResponding) - : this(url, CreateRealExecutor(url, timeForTheServerResponding)) + : this(CreateRealExecutor(url, timeForTheServerResponding)) { Service = null; } internal AppiumCommandExecutor(AppiumLocalService service, TimeSpan timeForTheServerResponding) - : this(service.ServiceUrl, CreateRealExecutor(service.ServiceUrl, timeForTheServerResponding)) + : this(CreateRealExecutor(service.ServiceUrl, timeForTheServerResponding)) { Service = service; } - public CommandInfoRepository CommandInfoRepository => RealExecutor.CommandInfoRepository; - public Response Execute(Command commandToExecute) { Response result = null; @@ -105,9 +89,8 @@ private ICommandExecutor ModifyNewSessionHttpRequestHeader(ICommandExecutor comm { if (commandExecutor == null) throw new ArgumentNullException(nameof(commandExecutor)); var modifiedCommandExecutor = commandExecutor as HttpCommandExecutor; - if (modifiedCommandExecutor != null) - modifiedCommandExecutor.SendingRemoteHttpRequest += (sender, args) => - args.Request.Headers.Add(IdempotencyHeader, Guid.NewGuid().ToString()); + modifiedCommandExecutor.SendingRemoteHttpRequest += (sender, args) => + args.AddHeader(IdempotencyHeader, Guid.NewGuid().ToString()); return modifiedCommandExecutor; } @@ -125,5 +108,10 @@ protected void Dispose(bool disposing) isDisposed = true; } } + + public bool TryAddCommand(string commandName, CommandInfo info) + { + return this.RealExecutor.TryAddCommand(commandName, info); + } } } \ No newline at end of file diff --git a/src/Appium.Net/Appium/Service/AppiumLocalService.cs b/src/Appium.Net/Appium/Service/AppiumLocalService.cs index 3c411aaf9..5461fbefa 100644 --- a/src/Appium.Net/Appium/Service/AppiumLocalService.cs +++ b/src/Appium.Net/Appium/Service/AppiumLocalService.cs @@ -12,12 +12,12 @@ //See the License for the specific language governing permissions and //limitations under the License. -using System; -using System.Collections.Generic; using OpenQA.Selenium.Appium.Service.Exceptions; using OpenQA.Selenium.Remote; -using System.IO; +using System; +using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Net; using System.Runtime.CompilerServices; diff --git a/src/Appium.Net/Appium/Service/Options/OptionCollector.cs b/src/Appium.Net/Appium/Service/Options/OptionCollector.cs index 29c0abf27..b64d41102 100644 --- a/src/Appium.Net/Appium/Service/Options/OptionCollector.cs +++ b/src/Appium.Net/Appium/Service/Options/OptionCollector.cs @@ -48,9 +48,9 @@ public OptionCollector AddCapabilities(AppiumOptions options) } else { - Dictionary originalDictionary = this.options.ToDictionary(); - Dictionary givenDictionary = options.ToDictionary(); - Dictionary result = new Dictionary(originalDictionary); + IDictionary originalDictionary = this.options.ToDictionary(); + IDictionary givenDictionary = options.ToDictionary(); + IDictionary result = new Dictionary(originalDictionary); foreach (var item in givenDictionary) { @@ -81,7 +81,7 @@ private string ParseCapabilitiesIfWindows() if (options != null) { - Dictionary capabilitiesDictionary = options.ToDictionary(); + IDictionary capabilitiesDictionary = options.ToDictionary(); foreach (var item in capabilitiesDictionary) { @@ -132,7 +132,7 @@ private string ParseCapabilitiesIfUNIX() if (options != null) { - Dictionary capabilitiesDictionary = options.ToDictionary(); + IDictionary capabilitiesDictionary = options.ToDictionary(); foreach (var item in capabilitiesDictionary) { diff --git a/src/Appium.Net/Appium/Tizen/TizenCommandExecutionHelper.cs b/src/Appium.Net/Appium/Tizen/TizenCommandExecutionHelper.cs index 810bde276..a0b20a237 100644 --- a/src/Appium.Net/Appium/Tizen/TizenCommandExecutionHelper.cs +++ b/src/Appium.Net/Appium/Tizen/TizenCommandExecutionHelper.cs @@ -13,7 +13,6 @@ //limitations under the License. using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Remote; using System.Collections.Generic; namespace OpenQA.Selenium.Appium.Tizen diff --git a/src/Appium.Net/Appium/Tizen/TizenDriver.cs b/src/Appium.Net/Appium/Tizen/TizenDriver.cs index 009f2efcc..990008d03 100644 --- a/src/Appium.Net/Appium/Tizen/TizenDriver.cs +++ b/src/Appium.Net/Appium/Tizen/TizenDriver.cs @@ -15,7 +15,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; using OpenQA.Selenium.Appium.Service; -using OpenQA.Selenium.Remote; using System; using System.Collections.Generic; @@ -138,6 +137,6 @@ public IReadOnlyCollection FindElementsByTizenUIAutomation(string selector) = #endregion IFindByTizenUIAutomation Members - protected override RemoteWebElementFactory CreateElementFactory() => new TizenElementFactory(this); + protected override WebElementFactory CreateElementFactory() => new TizenElementFactory(this as WebDriver); } } diff --git a/src/Appium.Net/Appium/Tizen/TizenElement.cs b/src/Appium.Net/Appium/Tizen/TizenElement.cs index e1f4efc22..1b7bf03d1 100644 --- a/src/Appium.Net/Appium/Tizen/TizenElement.cs +++ b/src/Appium.Net/Appium/Tizen/TizenElement.cs @@ -13,7 +13,6 @@ //limitations under the License. using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Remote; using System.Collections.Generic; namespace OpenQA.Selenium.Appium.Tizen @@ -25,7 +24,7 @@ public class TizenElement : AppiumWebElement, IFindByTizenUIAutomation /// Driver in use. /// ID of the element. - public TizenElement(RemoteWebDriver parent, string id) + public TizenElement(WebDriver parent, string id) : base(parent, id) { } diff --git a/src/Appium.Net/Appium/Tizen/TizenElementFactory.cs b/src/Appium.Net/Appium/Tizen/TizenElementFactory.cs index 6f05b6e48..48e02b6ef 100644 --- a/src/Appium.Net/Appium/Tizen/TizenElementFactory.cs +++ b/src/Appium.Net/Appium/Tizen/TizenElementFactory.cs @@ -1,14 +1,13 @@ -using OpenQA.Selenium.Remote; - + namespace OpenQA.Selenium.Appium.Tizen { public class TizenElementFactory : CachedElementFactory { - public TizenElementFactory(RemoteWebDriver parentDriver) : base(parentDriver) + public TizenElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected override TizenElement CreateCachedElement(RemoteWebDriver parentDriver, string elementId) + protected override TizenElement CreateCachedElement(WebDriver parentDriver, string elementId) { return new TizenElement(parentDriver, elementId); } diff --git a/src/Appium.Net/Appium/Windows/WindowsDriver.cs b/src/Appium.Net/Appium/Windows/WindowsDriver.cs index a2b5a0fbe..12ce29312 100644 --- a/src/Appium.Net/Appium/Windows/WindowsDriver.cs +++ b/src/Appium.Net/Appium/Windows/WindowsDriver.cs @@ -19,7 +19,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; using OpenQA.Selenium.Appium.Service; -using OpenQA.Selenium.Remote; namespace OpenQA.Selenium.Appium.Windows { @@ -154,7 +153,7 @@ public IReadOnlyCollection FindElementsByWindowsUIAutomation(string selector) public void HideKeyboard(string key, string strategy = null) => AppiumCommandExecutionHelper.HideKeyboard(this, strategy, key); - protected override RemoteWebElementFactory CreateElementFactory() => new WindowsElementFactory(this); + protected override WebElementFactory CreateElementFactory() => new WindowsElementFactory(this); public void PressKeyCode(KeyEvent keyEvent) => throw new NotImplementedException(); diff --git a/src/Appium.Net/Appium/Windows/WindowsElement.cs b/src/Appium.Net/Appium/Windows/WindowsElement.cs index 6438abc39..973c79c7c 100644 --- a/src/Appium.Net/Appium/Windows/WindowsElement.cs +++ b/src/Appium.Net/Appium/Windows/WindowsElement.cs @@ -13,7 +13,6 @@ //limitations under the License. using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Remote; using OpenQA.Selenium.Appium.Enums; using System.Collections.Generic; @@ -21,7 +20,7 @@ namespace OpenQA.Selenium.Appium.Windows { public class WindowsElement : AppiumWebElement, IFindByWindowsUIAutomation { - public WindowsElement(RemoteWebDriver parent, string id) + public WindowsElement(WebDriver parent, string id) : base(parent, id) { } diff --git a/src/Appium.Net/Appium/Windows/WindowsElementFactory.cs b/src/Appium.Net/Appium/Windows/WindowsElementFactory.cs index 24d3adb60..7d2318a65 100644 --- a/src/Appium.Net/Appium/Windows/WindowsElementFactory.cs +++ b/src/Appium.Net/Appium/Windows/WindowsElementFactory.cs @@ -1,14 +1,13 @@ -using OpenQA.Selenium.Remote; - + namespace OpenQA.Selenium.Appium.Windows { public class WindowsElementFactory : CachedElementFactory { - public WindowsElementFactory(RemoteWebDriver parentDriver) : base(parentDriver) + public WindowsElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected override WindowsElement CreateCachedElement(RemoteWebDriver parentDriver, string elementId) + protected override WindowsElement CreateCachedElement(WebDriver parentDriver, string elementId) { return new WindowsElement(parentDriver, elementId); } diff --git a/src/Appium.Net/Appium/iOS/IOSDriver.cs b/src/Appium.Net/Appium/iOS/IOSDriver.cs index 22c71146c..f987107d2 100644 --- a/src/Appium.Net/Appium/iOS/IOSDriver.cs +++ b/src/Appium.Net/Appium/iOS/IOSDriver.cs @@ -15,7 +15,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; using OpenQA.Selenium.Appium.Service; -using OpenQA.Selenium.Remote; using System; using System.Drawing; using OpenQA.Selenium.Appium.iOS.Interfaces; @@ -171,7 +170,7 @@ public Dictionary Settings public void HideKeyboard(string key, string strategy = null) => AppiumCommandExecutionHelper.HideKeyboard(this, strategy, key); - protected override RemoteWebElementFactory CreateElementFactory() => new IOSElementFactory(this); + protected override WebElementFactory CreateElementFactory() => new IOSElementFactory(this as WebDriver); /// /// Locks the device. diff --git a/src/Appium.Net/Appium/iOS/IOSElement.cs b/src/Appium.Net/Appium/iOS/IOSElement.cs index faf3e5241..1443dd078 100644 --- a/src/Appium.Net/Appium/iOS/IOSElement.cs +++ b/src/Appium.Net/Appium/iOS/IOSElement.cs @@ -14,7 +14,6 @@ using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Remote; using System.Collections.Generic; namespace OpenQA.Selenium.Appium.iOS @@ -27,7 +26,7 @@ public class IOSElement : AppiumWebElement, /// /// Driver in use. /// ID of the element. - public IOSElement(RemoteWebDriver parent, string id) + public IOSElement(WebDriver parent, string id) : base(parent, id) { } diff --git a/src/Appium.Net/Appium/iOS/IOSElementFactory.cs b/src/Appium.Net/Appium/iOS/IOSElementFactory.cs index ba77ba196..45e1a3180 100644 --- a/src/Appium.Net/Appium/iOS/IOSElementFactory.cs +++ b/src/Appium.Net/Appium/iOS/IOSElementFactory.cs @@ -1,14 +1,13 @@ -using OpenQA.Selenium.Remote; - + namespace OpenQA.Selenium.Appium.iOS { public class IOSElementFactory : CachedElementFactory { - public IOSElementFactory(RemoteWebDriver parentDriver) : base(parentDriver) + public IOSElementFactory(WebDriver parentDriver) : base(parentDriver) { } - protected override IOSElement CreateCachedElement(RemoteWebDriver parentDriver, string elementId) + protected override IOSElement CreateCachedElement(WebDriver parentDriver, string elementId) { return new IOSElement(parentDriver, elementId); } diff --git a/test/integration/Android/ClipboardTest.cs b/test/integration/Android/ClipboardTest.cs index 300709432..f5b65e5ff 100644 --- a/test/integration/Android/ClipboardTest.cs +++ b/test/integration/Android/ClipboardTest.cs @@ -21,7 +21,7 @@ public void BeforeAll() var capabilities = Env.ServerIsRemote() ? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")) : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); - capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec); _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec; diff --git a/test/integration/Android/Device/AuthenticationTest.cs b/test/integration/Android/Device/AuthenticationTest.cs index 0f8bb7dc0..ecb2b2d41 100644 --- a/test/integration/Android/Device/AuthenticationTest.cs +++ b/test/integration/Android/Device/AuthenticationTest.cs @@ -14,7 +14,7 @@ public class AuthenticationTest public void BeforeAll() { var capabilities = Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); - capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec); _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec; diff --git a/test/integration/Android/WebviewTest.cs b/test/integration/Android/WebviewTest.cs index 04c50db3c..92dcd92a9 100644 --- a/test/integration/Android/WebviewTest.cs +++ b/test/integration/Android/WebviewTest.cs @@ -20,8 +20,8 @@ public void BeforeAll() var capabilities = Env.ServerIsRemote() ? Caps.GetAndroidUIAutomatorCaps(Apps.Get("selendroidTestApp")) : Caps.GetAndroidUIAutomatorCaps(Apps.Get("selendroidTestApp")); - capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.selendroid.testapp"); - capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".WebViewActivity"); + capabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppPackage, "io.selendroid.testapp"); + capabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppActivity, ".WebViewActivity"); var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec); _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec; diff --git a/test/integration/Appium.Net.Integration.Tests.csproj b/test/integration/Appium.Net.Integration.Tests.csproj index 6ed22301d..551852ec1 100644 --- a/test/integration/Appium.Net.Integration.Tests.csproj +++ b/test/integration/Appium.Net.Integration.Tests.csproj @@ -9,13 +9,10 @@ - - + - - diff --git a/test/integration/IOS/ClipboardTest.cs b/test/integration/IOS/ClipboardTest.cs index 1f582a7fc..1ece245c9 100644 --- a/test/integration/IOS/ClipboardTest.cs +++ b/test/integration/IOS/ClipboardTest.cs @@ -22,7 +22,7 @@ public class ClipboardTest public void Setup() { var capabilities = Caps.GetIosCaps(Apps.Get("iosUICatalogApp")); - capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new IOSDriver(serverUri, capabilities, Env.InitTimeoutSec); diff --git a/test/integration/IOS/SearchingTest.cs b/test/integration/IOS/SearchingTest.cs index 7a1bd1156..cb62cd56e 100644 --- a/test/integration/IOS/SearchingTest.cs +++ b/test/integration/IOS/SearchingTest.cs @@ -16,10 +16,10 @@ public void BeforeAll() var capabilities = Caps.GetIosCaps(Apps.Get("iosTestApp")); if (Env.ServerIsRemote()) { - capabilities.AddAdditionalCapability("username", Env.GetEnvVar("SAUCE_USERNAME")); - capabilities.AddAdditionalCapability("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); - capabilities.AddAdditionalCapability("name", "ios - simple"); - capabilities.AddAdditionalCapability("tags", new[] {"sample"}); + capabilities.AddAdditionalAppiumOption("username", Env.GetEnvVar("SAUCE_USERNAME")); + capabilities.AddAdditionalAppiumOption("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); + capabilities.AddAdditionalAppiumOption("name", "ios - simple"); + capabilities.AddAdditionalAppiumOption("tags", new[] {"sample"}); } var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new IOSDriver(serverUri, capabilities, Env.InitTimeoutSec); diff --git a/test/integration/IOS/TouchActionTest.cs b/test/integration/IOS/TouchActionTest.cs index 82dd65fb6..caf0ee735 100644 --- a/test/integration/IOS/TouchActionTest.cs +++ b/test/integration/IOS/TouchActionTest.cs @@ -19,10 +19,10 @@ public void BeforeAll() var capabilities = Caps.GetIosCaps(Apps.Get("iosTestApp")); if (Env.ServerIsRemote()) { - capabilities.AddAdditionalCapability("username", Env.GetEnvVar("SAUCE_USERNAME")); - capabilities.AddAdditionalCapability("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); - capabilities.AddAdditionalCapability("name", "ios - actions"); - capabilities.AddAdditionalCapability("tags", new[] {"sample"}); + capabilities.AddAdditionalAppiumOption("username", Env.GetEnvVar("SAUCE_USERNAME")); + capabilities.AddAdditionalAppiumOption("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); + capabilities.AddAdditionalAppiumOption("name", "ios - actions"); + capabilities.AddAdditionalAppiumOption("tags", new[] {"sample"}); } var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new IOSDriver(serverUri, capabilities, Env.InitTimeoutSec); diff --git a/test/integration/IOS/WebviewTest.cs b/test/integration/IOS/WebviewTest.cs index d47a306d2..1576fc99a 100644 --- a/test/integration/IOS/WebviewTest.cs +++ b/test/integration/IOS/WebviewTest.cs @@ -18,10 +18,10 @@ public void BeforeAll() var capabilities = Caps.GetIosCaps(Apps.Get("iosWebviewApp")); if (Env.ServerIsRemote()) { - capabilities.AddAdditionalCapability("username", Env.GetEnvVar("SAUCE_USERNAME")); - capabilities.AddAdditionalCapability("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); - capabilities.AddAdditionalCapability("name", "ios - webview"); - capabilities.AddAdditionalCapability("tags", new[] {"sample"}); + capabilities.AddAdditionalAppiumOption("username", Env.GetEnvVar("SAUCE_USERNAME")); + capabilities.AddAdditionalAppiumOption("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); + capabilities.AddAdditionalAppiumOption("name", "ios - webview"); + capabilities.AddAdditionalAppiumOption("tags", new[] {"sample"}); } var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new IOSDriver(serverUri, capabilities, Env.InitTimeoutSec); diff --git a/test/integration/Mac/AlertTest.cs b/test/integration/Mac/AlertTest.cs index 91c4f1caa..edc691a88 100644 --- a/test/integration/Mac/AlertTest.cs +++ b/test/integration/Mac/AlertTest.cs @@ -14,7 +14,7 @@ public class FindElementTest public void BeforeAll() { var capabilities = new AppiumOptions(); - capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Mac"); // Requires until Appium 1.15.1 + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.DeviceName, "Mac"); // Requires until Appium 1.15.1 var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _driver = new MacDriver(serverUri, capabilities, Env.InitTimeoutSec); _driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec; diff --git a/test/integration/PageObjectTests/IOS/NativeAppAttributesTest.cs b/test/integration/PageObjectTests/IOS/NativeAppAttributesTest.cs index 39caa357a..bebb3c118 100644 --- a/test/integration/PageObjectTests/IOS/NativeAppAttributesTest.cs +++ b/test/integration/PageObjectTests/IOS/NativeAppAttributesTest.cs @@ -21,10 +21,10 @@ public void BeforeAll() var capabilities = Caps.GetIosCaps(Apps.Get("iosTestApp")); if (Env.ServerIsRemote()) { - capabilities.AddAdditionalCapability("username", Env.GetEnvVar("SAUCE_USERNAME")); - capabilities.AddAdditionalCapability("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); - capabilities.AddAdditionalCapability("name", "ios - actions"); - capabilities.AddAdditionalCapability("tags", new[] {"sample"}); + capabilities.AddAdditionalAppiumOption("username", Env.GetEnvVar("SAUCE_USERNAME")); + capabilities.AddAdditionalAppiumOption("accessKey", Env.GetEnvVar("SAUCE_ACCESS_KEY")); + capabilities.AddAdditionalAppiumOption("name", "ios - actions"); + capabilities.AddAdditionalAppiumOption("tags", new[] {"sample"}); } var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; diff --git a/test/integration/PageObjectTests/Windows/WindowsAlarmAppTest.cs b/test/integration/PageObjectTests/Windows/WindowsAlarmAppTest.cs index 699c59e9e..273af9546 100644 --- a/test/integration/PageObjectTests/Windows/WindowsAlarmAppTest.cs +++ b/test/integration/PageObjectTests/Windows/WindowsAlarmAppTest.cs @@ -16,9 +16,9 @@ public class WindowsAlarmAppTest public void Setup() { var appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"); - appCapabilities.AddAdditionalCapability("platformName", "Windows"); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + appCapabilities.App = "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"; + appCapabilities.PlatformName ="Windows"; + appCapabilities.DeviceName = "WindowsPC"; var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; diff --git a/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp1.cs b/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp1.cs index 2af44d160..6a2abf926 100644 --- a/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp1.cs +++ b/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp1.cs @@ -114,7 +114,7 @@ [FindsByAll] [MobileFindsByAll(Android = true)] [FindsBy(How = How.Id, Using = " [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement _matchedToAllLocatorsElement; @@ -123,7 +123,7 @@ [FindsByAll] [MobileFindsByAll(Android = true)] [FindsBy(How = How.Id, Using = " [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList _matchedToAllLocatorsElements; @@ -135,7 +135,7 @@ [FindsByAll] [MobileFindsByAll(Android = true)] [FindsBy(How = How.Id, Using = " [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement TestMatchedToAllLocatorsElementProperty { set; get; } @@ -146,7 +146,7 @@ [FindsByAll] [MobileFindsByAll(Android = true)] [FindsBy(How = How.Id, Using = " [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList TestMatchedToAllLocatorsElementsProperty { set; get; } diff --git a/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp2.cs b/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp2.cs index dba2c5310..5fb4333a7 100644 --- a/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp2.cs +++ b/test/integration/PageObjects/AndroidPageObjectChecksAttributeMixOnNativeApp2.cs @@ -146,7 +146,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsByIOSUIAutomation(IosUIAutomation = ".elements()[2]", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement _matchedToAllLocatorsElement; @@ -159,7 +159,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsByIOSUIAutomation(IosUIAutomation = ".elements()[2]", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList _matchedToAllLocatorsElements; @@ -175,7 +175,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsByIOSUIAutomation(IosUIAutomation = ".elements()[2]", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement TestMatchedToAllLocatorsElementProperty { set; get; } @@ -189,7 +189,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsByIOSUIAutomation(IosUIAutomation = ".elements()[2]", Priority = 3)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList TestMatchedToAllLocatorsElementsProperty { set; get; } diff --git a/test/integration/PageObjects/AndroidPageObjectChecksAttributesForNativeAndroidApp.cs b/test/integration/PageObjects/AndroidPageObjectChecksAttributesForNativeAndroidApp.cs index be14a70f4..a52c705bb 100644 --- a/test/integration/PageObjects/AndroidPageObjectChecksAttributesForNativeAndroidApp.cs +++ b/test/integration/PageObjects/AndroidPageObjectChecksAttributesForNativeAndroidApp.cs @@ -102,13 +102,13 @@ private IList TestFoundByChainedSearchElementsProperty [MobileFindsByAll(Android = true)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement _matchedToAllLocatorsElement; [MobileFindsByAll(Android = true)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList _matchedToAllLocatorsElements; @@ -121,7 +121,7 @@ private IList TestFoundByChainedSearchElementsProperty [MobileFindsByAll(Android = true)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement TestMatchedToAllLocatorsElementProperty { @@ -132,7 +132,7 @@ private IMobileElement TestMatchedToAllLocatorsElementProperty [MobileFindsByAll(Android = true)] [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] //[FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList TestMatchedToAllLocatorsElementsProperty { diff --git a/test/integration/PageObjects/AndroidPageObjectChecksSelendroidModeOnNativeApp.cs b/test/integration/PageObjects/AndroidPageObjectChecksSelendroidModeOnNativeApp.cs index e2da8514b..46f79c109 100644 --- a/test/integration/PageObjects/AndroidPageObjectChecksSelendroidModeOnNativeApp.cs +++ b/test/integration/PageObjects/AndroidPageObjectChecksSelendroidModeOnNativeApp.cs @@ -92,14 +92,14 @@ public class AndroidPageObjectChecksSelendroidModeOnNativeApp [MobileFindsByAll(Selendroid = true)] [FindsBySelendroid(LinkText = "Press to throw unhandled exception", Priority = 1)] //[FindsByAndroidUIAutomator(ID = "waitingButtonTest", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement _matchedToAllLocatorsElement; [MobileFindsByAll(Selendroid = true)] [FindsBySelendroid(LinkText = "Press to throw unhandled exception", Priority = 1)] //[FindsByAndroidUIAutomator(ID = "waitingButtonTest", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList _matchedToAllLocatorsElements; @@ -108,14 +108,14 @@ public class AndroidPageObjectChecksSelendroidModeOnNativeApp [MobileFindsByAll(Selendroid = true)] [FindsBySelendroid(LinkText = "Press to throw unhandled exception", Priority = 1)] //[FindsByAndroidUIAutomator(ID = "waitingButtonTest", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IWebElement TestMatchedToAllLocatorsElementProperty { set; get; } [MobileFindsByAll(Selendroid = true)] [FindsBySelendroid(LinkText = "Press to throw unhandled exception", Priority = 1)] //[FindsByAndroidUIAutomator(ID = "waitingButtonTest", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList TestMatchedToAllLocatorsElementsProperty { set; get; } diff --git a/test/integration/PageObjects/AndroidPageObjectChecksSeleniumFindsByCompatibility.cs b/test/integration/PageObjects/AndroidPageObjectChecksSeleniumFindsByCompatibility.cs index 6f20c3542..835e07e6c 100644 --- a/test/integration/PageObjects/AndroidPageObjectChecksSeleniumFindsByCompatibility.cs +++ b/test/integration/PageObjects/AndroidPageObjectChecksSeleniumFindsByCompatibility.cs @@ -83,13 +83,13 @@ [FindsBySequence] [FindsBy(How = How.Id, Using = "android:id/content", Priority [FindsByAll] [FindsBy(How = How.Id, Using = "android:id/text1", Priority = 1)] //[FindsBy(How = How.ClassName, Using = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement _matchedToAllLocatorsElement; [FindsByAll] [FindsBy(How = How.Id, Using = "android:id/text1", Priority = 1)] //[FindsBy(How = How.ClassName, Using = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList _matchedToAllLocatorsElements; @@ -97,14 +97,14 @@ [FindsByAll] [FindsBy(How = How.Id, Using = "android:id/text1", Priority = 1)] [FindsByAll] [FindsBy(How = How.Id, Using = "android:id/text1", Priority = 1)] //[FindsBy(How = How.ClassName, Using = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IMobileElement TestMatchedToAllLocatorsElementProperty { set; get; } [FindsByAll] [FindsBy(How = How.Id, Using = "android:id/text1", Priority = 1)] //[FindsBy(How = How.ClassName, Using = "android.widget.TextView", Priority = 2)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector will be commented till the problem is worked out private IList TestMatchedToAllLocatorsElementsProperty { set; get; } diff --git a/test/integration/PageObjects/IOSPageObjectChecksAttributeMixOnNativeApp.cs b/test/integration/PageObjects/IOSPageObjectChecksAttributeMixOnNativeApp.cs index 5b9a064b2..7b6be887e 100644 --- a/test/integration/PageObjects/IOSPageObjectChecksAttributeMixOnNativeApp.cs +++ b/test/integration/PageObjects/IOSPageObjectChecksAttributeMixOnNativeApp.cs @@ -83,7 +83,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsBy(How = How.ClassName, Using = "FakeHTMLClass", Priority = 2)] [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] [FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 1)] @@ -94,7 +94,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsBy(How = How.ClassName, Using = "FakeHTMLClass", Priority = 2)] [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] [FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 1)] @@ -107,7 +107,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsBy(How = How.ClassName, Using = "FakeHTMLClass", Priority = 2)] [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] [FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 1)] @@ -119,7 +119,7 @@ [FindsByAll] [MobileFindsByAll(Android = true, IOS = true)] [FindsBy(How = How.ClassName, Using = "FakeHTMLClass", Priority = 2)] [FindsBy(How = How.XPath, Using = ".//fakeTag", Priority = 3)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out [FindsByAndroidUIAutomator(ID = "android:id/text1", Priority = 1)] [FindsByAndroidUIAutomator(ClassName = "android.widget.TextView", Priority = 1)] diff --git a/test/integration/PageObjects/IOSPageObjectChecksAttributesForNativeIOSApp.cs b/test/integration/PageObjects/IOSPageObjectChecksAttributesForNativeIOSApp.cs index b658e8ecc..fea7aad3f 100644 --- a/test/integration/PageObjects/IOSPageObjectChecksAttributesForNativeIOSApp.cs +++ b/test/integration/PageObjects/IOSPageObjectChecksAttributesForNativeIOSApp.cs @@ -43,12 +43,12 @@ public class IosPageObjectChecksAttributesForNativeIosApp private IList MultipleFindByElementsProperty { set; get; } [MobileFindsByAll(IOS = true)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out private IMobileElement _matchedToAllLocatorsElement; [MobileFindsByAll(IOS = true)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out private IList _matchedToAllLocatorsElements; @@ -56,13 +56,13 @@ public class IosPageObjectChecksAttributesForNativeIosApp [MobileFindsByAll(IOS = true)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out private IMobileElement TestMatchedToAllLocatorsElementProperty { set; get; } [MobileFindsByAll(IOS = true)] [FindsByIOSUIAutomation(ClassName = "UIAButton", Priority = 1)] - //Equals method of RemoteWebElement is not consistent for mobile apps + //Equals method of WebElement is not consistent for mobile apps //The second selector won't be added till the problem is worked out private IList TestMatchedToAllLocatorsElementsProperty { set; get; } diff --git a/test/integration/PageObjects/WindowsAlarmApp.cs b/test/integration/PageObjects/WindowsAlarmApp.cs index 5978563e0..7b7c82178 100644 --- a/test/integration/PageObjects/WindowsAlarmApp.cs +++ b/test/integration/PageObjects/WindowsAlarmApp.cs @@ -119,7 +119,8 @@ public void DeleteAlarmWithName(string alarmName) { var alarmEntry = _driver.FindElementByName(alarmName); - _driver.Mouse.ContextClick(alarmEntry.Coordinates); + /////// TODO - Implement for Appium + ////// _driver.Mouse.ContextClick(alarmEntry.Coordinates); _driver.FindElementByName("Delete").Click(); } } diff --git a/test/integration/ServerTests/AppiumLocalServerLaunchingTest.cs b/test/integration/ServerTests/AppiumLocalServerLaunchingTest.cs index 69de0a94c..2b23ec1d1 100644 --- a/test/integration/ServerTests/AppiumLocalServerLaunchingTest.cs +++ b/test/integration/ServerTests/AppiumLocalServerLaunchingTest.cs @@ -188,11 +188,11 @@ public void CheckAbilityToStartServiceUsingFlags() public void CheckAbilityToStartServiceUsingCapabilities() { var capabilities = new AppiumOptions(); - capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android"); - capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true); - capabilities.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 60); - capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis"); - capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1"); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.PlatformName, "Android"); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 60); + capabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis"); + capabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppActivity, ".view.WebView1"); var args = new OptionCollector().AddCapabilities(capabilities); AppiumLocalService service = null; @@ -212,11 +212,11 @@ public void CheckAbilityToStartServiceUsingCapabilities() public void CheckAbilityToStartServiceUsingCapabilitiesAndFlags() { var capabilities = new AppiumOptions(); - capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android"); - capabilities.AddAdditionalCapability(MobileCapabilityType.FullReset, true); - capabilities.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 60); - capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis"); - capabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1"); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.PlatformName, "Android"); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.FullReset, true); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.NewCommandTimeout, 60); + capabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis"); + capabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppActivity, ".view.WebView1"); var args = new OptionCollector().AddCapabilities(capabilities) .AddArguments(GeneralOptionList.CallbackAddress(_testIp)) diff --git a/test/integration/ServerTests/StartingAppLocallyTest.cs b/test/integration/ServerTests/StartingAppLocallyTest.cs index 3ff161d55..4e1872b5e 100644 --- a/test/integration/ServerTests/StartingAppLocallyTest.cs +++ b/test/integration/ServerTests/StartingAppLocallyTest.cs @@ -66,8 +66,8 @@ public void StartingAndroidAppWithCapabilitiesOnTheServerSideTest() : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); var clientCapabilities = new AppiumOptions(); - clientCapabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis"); - clientCapabilities.AddAdditionalCapability(AndroidMobileCapabilityType.AppActivity, ".view.WebView1"); + clientCapabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppPackage, "io.appium.android.apis"); + clientCapabilities.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppActivity, ".view.WebView1"); var argCollector = new OptionCollector().AddCapabilities(serverCapabilities); var builder = new AppiumServiceBuilder().WithArguments(argCollector); @@ -133,8 +133,8 @@ public void CheckThatServiseIsNotRunWhenTheCreatingOfANewSessionIsFailed() ? //it will be a cause of error Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")) : Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos")); - capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone Simulator"); - capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformName, MobilePlatform.IOS); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.DeviceName, "iPhone Simulator"); + capabilities.AddAdditionalAppiumOption(MobileCapabilityType.PlatformName, MobilePlatform.IOS); var builder = new AppiumServiceBuilder(); var service = builder.Build(); diff --git a/test/integration/Windows/ClickElementTest.cs b/test/integration/Windows/ClickElementTest.cs index 7e6a8f852..95cbdb6a0 100644 --- a/test/integration/Windows/ClickElementTest.cs +++ b/test/integration/Windows/ClickElementTest.cs @@ -14,24 +14,24 @@ using Appium.Net.Integration.Tests.helpers; using NUnit.Framework; +using OpenQA.Selenium; using OpenQA.Selenium.Appium; using OpenQA.Selenium.Appium.Windows; -using OpenQA.Selenium.Remote; namespace Appium.Net.Integration.Tests.Windows { public class ClickElementTest { private WindowsDriver _calculatorSession; - protected static RemoteWebElement CalculatorResult; + protected static WebElement CalculatorResult; [OneTimeSetUp] public void BeforeAll() { var appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); - appCapabilities.AddAdditionalCapability("platformName", "Windows"); + appCapabilities.App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"; + appCapabilities.DeviceName = "WindowsPC"; + appCapabilities.PlatformName ="Windows"; var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _calculatorSession = new WindowsDriver(serverUri, appCapabilities, @@ -40,7 +40,7 @@ public void BeforeAll() _calculatorSession.FindElementByName("Clear").Click(); _calculatorSession.FindElementByName("Seven").Click(); - CalculatorResult = _calculatorSession.FindElementByName("Display is 7") as RemoteWebElement; + CalculatorResult = _calculatorSession.FindElementByName("Display is 7") as WebElement; Assert.IsNotNull(CalculatorResult); } diff --git a/test/integration/Windows/ImagesComparisonTest.cs b/test/integration/Windows/ImagesComparisonTest.cs index e5779cc78..9c64d3baf 100644 --- a/test/integration/Windows/ImagesComparisonTest.cs +++ b/test/integration/Windows/ImagesComparisonTest.cs @@ -1,24 +1,24 @@ using Appium.Net.Integration.Tests.helpers; using NUnit.Framework; +using OpenQA.Selenium; using OpenQA.Selenium.Appium; using OpenQA.Selenium.Appium.ImageComparison; using OpenQA.Selenium.Appium.Windows; -using OpenQA.Selenium.Remote; namespace Appium.Net.Integration.Tests.Windows { public class ImagesComparisonTest { private WindowsDriver _calculatorSession; - protected static RemoteWebElement CalculatorResult; + protected static WebElement CalculatorResult; [OneTimeSetUp] public void BeforeAll() { var appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); - appCapabilities.AddAdditionalCapability("platformName", "Windows"); + appCapabilities.App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"; + appCapabilities.DeviceName = "WindowsPC"; + appCapabilities.PlatformName ="Windows"; var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; _calculatorSession = new WindowsDriver(serverUri, appCapabilities, diff --git a/test/integration/Windows/MultiSelectControlTest.cs b/test/integration/Windows/MultiSelectControlTest.cs index b6562913c..0a1cd52d5 100644 --- a/test/integration/Windows/MultiSelectControlTest.cs +++ b/test/integration/Windows/MultiSelectControlTest.cs @@ -35,9 +35,9 @@ public void Setup() { // Launch the AlarmClock app var appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"); - appCapabilities.AddAdditionalCapability("platformName", "Windows"); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + appCapabilities.App = "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App"; + appCapabilities.PlatformName ="Windows"; + appCapabilities.DeviceName = "WindowsPC"; var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri; @@ -49,8 +49,8 @@ public void Setup() // Create a session for Desktop var desktopCapabilities = new AppiumOptions(); - desktopCapabilities.AddAdditionalCapability("app", "Root"); - desktopCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + desktopCapabilities.App = "Root"; + desktopCapabilities.DeviceName = "WindowsPC"; DesktopSession = new WindowsDriver(serverUri, desktopCapabilities); @@ -70,7 +70,8 @@ public void OneTimeTearDown() var alarmEntries = AlarmClockSession.FindElementsByName("Windows Application Driver Test Alarm"); foreach (var alarmEntry in alarmEntries) { - AlarmClockSession.Mouse.ContextClick(alarmEntry.Coordinates); + /////// TODO - Implement for Appium + //// AlarmClockSession.Mouse.ContextClick(alarmEntry.Coordinates); AlarmClockSession.FindElementByName("Delete").Click(); } diff --git a/test/integration/Windows/PentTest.cs b/test/integration/Windows/PentTest.cs index 3029426f5..a58eab9da 100644 --- a/test/integration/Windows/PentTest.cs +++ b/test/integration/Windows/PentTest.cs @@ -236,8 +236,8 @@ public void CreateNewStickyNote() var newStickyNoteWindowHandle = openedStickyNotes[0].GetAttribute("NativeWindowHandle"); newStickyNoteWindowHandle = (int.Parse(newStickyNoteWindowHandle)).ToString("x"); // Convert to Hex AppiumOptions appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("appTopLevelWindow", newStickyNoteWindowHandle); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + appCapabilities.AddAdditionalAppiumOption("appTopLevelWindow", newStickyNoteWindowHandle); + appCapabilities.DeviceName = "WindowsPC"; newStickyNoteSession = new WindowsDriver(serverUri, appCapabilities); Assert.IsNotNull(newStickyNoteSession); @@ -259,7 +259,8 @@ public void DeleteStickyNote() if (newStickyNoteSession != null) { // Create a new Sticky Note by pressing Ctrl + N - newStickyNoteSession.Keyboard.SendKeys(Keys.Control + "d" + Keys.Control); + /////// TODO - Implement for Appium + //// newStickyNoteSession.Keyboard.SendKeys(Keys.Control + "d" + Keys.Control); Thread.Sleep(TimeSpan.FromSeconds(2)); try diff --git a/test/integration/Windows/StickyNotesTest.cs b/test/integration/Windows/StickyNotesTest.cs index 1ab55f2c7..573c5bfaf 100644 --- a/test/integration/Windows/StickyNotesTest.cs +++ b/test/integration/Windows/StickyNotesTest.cs @@ -41,8 +41,8 @@ public void BeforeAll() // Create a new session to launch or bring up Sticky Notes application // Note: All sticky note windows are parented to Modern_Sticky_Top_Window pane AppiumOptions appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("app", StickyNotesAppId); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + appCapabilities.App = StickyNotesAppId; + appCapabilities.DeviceName = "WindowsPC"; session = new WindowsDriver(serverUri, appCapabilities); } catch @@ -51,8 +51,8 @@ public void BeforeAll() // In such failure, simply look for the Modern_Sticky_Top_Window pane using the Desktop // session and create a new session based on the located top window pane. AppiumOptions desktopCapabilities = new AppiumOptions(); - desktopCapabilities.AddAdditionalCapability("app", "Root"); - desktopCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + desktopCapabilities.App = "Root"; + desktopCapabilities.DeviceName = "WindowsPC"; var desktopSession = new WindowsDriver(serverUri, desktopCapabilities); var StickyNotesTopLevelWindow = desktopSession.FindElementByClassName("Modern_Sticky_Top_Window"); @@ -60,8 +60,8 @@ public void BeforeAll() StickyNotesTopLevelWindowHandle = (int.Parse(StickyNotesTopLevelWindowHandle)).ToString("x"); // Convert to Hex AppiumOptions appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("appTopLevelWindow", StickyNotesTopLevelWindowHandle); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + appCapabilities.AddAdditionalOption("appTopLevelWindow", StickyNotesTopLevelWindowHandle); + appCapabilities.DeviceName = "WindowsPC"; session = new WindowsDriver(serverUri, appCapabilities); } Assert.IsNotNull(session); @@ -90,8 +90,8 @@ public void AfterAll() newStickyNoteWindowHandle = (int.Parse(newStickyNoteWindowHandle)).ToString("x"); // Convert to Hex AppiumOptions appCapabilities = new AppiumOptions(); - appCapabilities.AddAdditionalCapability("appTopLevelWindow", newStickyNoteWindowHandle); - appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC"); + appCapabilities.AddAdditionalAppiumOption("appTopLevelWindow", newStickyNoteWindowHandle); + appCapabilities.DeviceName = "WindowsPC"; var stickyNoteSession = new WindowsDriver(serverUri, appCapabilities); stickyNoteSession.Close(); } diff --git a/test/integration/helpers/Caps.cs b/test/integration/helpers/Caps.cs index f2da11ef5..181102f6d 100644 --- a/test/integration/helpers/Caps.cs +++ b/test/integration/helpers/Caps.cs @@ -8,11 +8,11 @@ public class Caps public static AppiumOptions GetIosCaps(string app) { var capabilities = new AppiumOptions(); - capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, AutomationName.iOSXcuiTest); - capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone X"); - capabilities.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "12.0"); - capabilities.AddAdditionalCapability(MobileCapabilityType.App, app); - capabilities.AddAdditionalCapability(IOSMobileCapabilityType.LaunchTimeout, Env.InitTimeoutSec.TotalMilliseconds); + capabilities.AutomationName = AutomationName.iOSXcuiTest; + capabilities.DeviceName = "iPhone X"; + capabilities.PlatformVersion = "12.0"; + capabilities.App = app; + capabilities.AddAdditionalAppiumOption(IOSMobileCapabilityType.LaunchTimeout, Env.InitTimeoutSec.TotalMilliseconds); return capabilities; } @@ -20,18 +20,18 @@ public static AppiumOptions GetIosCaps(string app) public static AppiumOptions GetAndroidUIAutomatorCaps(string app) { var capabilities = new AppiumOptions(); - capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, AutomationName.AndroidUIAutomator2); - capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android Emulator"); - capabilities.AddAdditionalCapability(MobileCapabilityType.App, app); + capabilities.AutomationName = AutomationName.AndroidUIAutomator2; + capabilities.DeviceName = "Android Emulator"; + capabilities.App = app; return capabilities; } public static AppiumOptions GetAndroidEspressoCaps(string app) { var capabilities = new AppiumOptions(); - capabilities.AddAdditionalCapability(MobileCapabilityType.AutomationName, AutomationName.AndroidEspresso); - capabilities.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Android Emulator"); - capabilities.AddAdditionalCapability(MobileCapabilityType.App, app); + capabilities.AutomationName = AutomationName.AndroidEspresso; + capabilities.DeviceName = "Android Emulator"; + capabilities.App = app; return capabilities; } }