diff --git a/src/Appium.Net/Appium/AppiumCommand.cs b/src/Appium.Net/Appium/AppiumCommand.cs index 8964c1c6..82edd80e 100644 --- a/src/Appium.Net/Appium/AppiumCommand.cs +++ b/src/Appium.Net/Appium/AppiumCommand.cs @@ -154,15 +154,6 @@ public class AppiumCommand #endregion Driver Commands - #region (Deprecated) Touch Commands - // TODO: Remove this region once we deprecate the touch actions - // Please use the W3C Actions instead. - new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PerformMultiAction, - "/session/{sessionId}/touch/multi/perform"), - new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.PerformTouchAction, - "/session/{sessionId}/touch/perform"), - - #endregion (Deprecated) Touch Commands // Enable W3C Actions on AppiumWebDriver diff --git a/src/Appium.Net/Appium/AppiumDriver.cs b/src/Appium.Net/Appium/AppiumDriver.cs index a5cd423b..5ecd8bc2 100644 --- a/src/Appium.Net/Appium/AppiumDriver.cs +++ b/src/Appium.Net/Appium/AppiumDriver.cs @@ -31,7 +31,7 @@ public abstract class AppiumDriver : WebDriver, IHasSessionDetails, IHasLocation, IHidesKeyboard, IInteractsWithFiles, IFindsByFluentSelector, - IInteractsWithApps, IPerformsTouchActions, IRotatable, IContextAware + IInteractsWithApps, IRotatable, IContextAware { private const string NativeApp = "NATIVE_APP"; @@ -386,26 +386,6 @@ public void DeactiveIMEEngine() => #endregion Input Method (IME) - #region (Deprecated) Multi Actions - // TODO: Remove this region once we deprecate the touch actions - // Please use the W3C Actions instead. - [Obsolete("Touch Actions are deprecated in W3C spec, please use W3C actions instead")] - public void PerformMultiAction(IMultiAction multiAction) - { - if (multiAction == null) return; - var parameters = multiAction.GetParameters(); - Execute(AppiumDriverCommand.PerformMultiAction, parameters); - } - [Obsolete("Touch Actions are deprecated in W3C spec, please use W3C actions instead")] - public void PerformTouchAction(ITouchAction touchAction) - { - if (touchAction == null) return; - var parameters = AppiumCommandExecutionHelper.PrepareArgument("actions", touchAction.GetParameters()); - Execute(AppiumDriverCommand.PerformTouchAction, parameters); - } - - #endregion (Deprecated) Multi Actions - #region W3C Actions // Replace or hide the original RemoteWebElement.PerformActions base method so that it does not require diff --git a/src/Appium.Net/Appium/AppiumDriverCommand.cs b/src/Appium.Net/Appium/AppiumDriverCommand.cs index 219609f7..6b9b371c 100644 --- a/src/Appium.Net/Appium/AppiumDriverCommand.cs +++ b/src/Appium.Net/Appium/AppiumDriverCommand.cs @@ -213,22 +213,6 @@ public class AppiumDriverCommand #endregion Appium Specific extensions to JSONWP Commands - #region (Deprecated) TouchActions - // TODO: Remove this region once we deprecate the touch actions - // Please use the W3C Actions instead. - - /// - /// Perform touch action - /// - public const string PerformTouchAction = "performTouchAction"; - - /// - /// Perform multi touch action - /// - public const string PerformMultiAction = "performMultiTouch"; - - #endregion (Deprecated) MultiTouchActions - #region W3C Actions /// diff --git a/src/Appium.Net/Appium/Interfaces/IPerformsTouchActions.cs b/src/Appium.Net/Appium/Interfaces/IPerformsTouchActions.cs deleted file mode 100644 index a4481805..00000000 --- a/src/Appium.Net/Appium/Interfaces/IPerformsTouchActions.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -using System; - -namespace OpenQA.Selenium.Appium.Interfaces -{ - /// - /// Provides a mechanism for building advanced interactions with the browser/application. - /// - [Obsolete("Touch Actions are deprecated in W3C spec, please use W3C actions instead")] - public interface IPerformsTouchActions - { - /// - /// Performs the multi-action sequence. - /// - /// Multi-action to perform. - void PerformMultiAction(IMultiAction multiAction); - - /// - /// Perform the touch-action sequence. - /// - /// touch action to perform - void PerformTouchAction(ITouchAction touchAction); - } -} \ No newline at end of file diff --git a/src/Appium.Net/Appium/MultiAction/MultiAction.cs b/src/Appium.Net/Appium/MultiAction/MultiAction.cs deleted file mode 100644 index cfaa847b..00000000 --- a/src/Appium.Net/Appium/MultiAction/MultiAction.cs +++ /dev/null @@ -1,98 +0,0 @@ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//See the NOTICE file distributed with this work for additional -//information regarding copyright ownership. -//You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. - -using System; -using System.Collections.Generic; -using OpenQA.Selenium.Appium.Interfaces; - -namespace OpenQA.Selenium.Appium.MultiTouch -{ - [Obsolete("MultiAction is deprecated, please use W3C actions instead: http://appium.io/docs/en/commands/interactions/actions/")] - public class MultiAction : IMultiAction - { - private IList actions = new List(); - - private IPerformsTouchActions TouchActionPerformer; - - /// - /// Initializes a new instance of the class. - /// - /// The the driver to be used. - public MultiAction(IPerformsTouchActions touchActionPerformer) - { - this.TouchActionPerformer = touchActionPerformer; - } - - - /// - /// Add touch actions to be performed - /// - /// - public IMultiAction Add(ITouchAction touchAction) - { - if (null == touchAction) - { - throw new ArgumentNullException("touchAction"); - } - - actions.Add(touchAction); - return this; - } - - /// - /// Gets the actions parameter dictionary for this multi touch action - /// - /// empty dictionary if no actions found, else dictionary of actions - public Dictionary GetParameters() - { - Dictionary parameters = new Dictionary(); - parameters.Add("actions", new List()); - - for (int i = 0; i < actions.Count; i++) - { - ((List) parameters["actions"]) - .Add(((TouchAction) actions[i]).GetParameters()); - } - return parameters; - } - - /// - /// Cancels the Multi Action - /// - public void Cancel() - { - actions.Clear(); - } - - /// - /// Executes the Multi Action - /// - public void Perform() - { - if (actions.Count == 1) - { - TouchActionPerformer.PerformTouchAction(actions[0]); - } - if (actions.Count > 1) - { - TouchActionPerformer.PerformMultiAction(this); - } - if (actions.Count == 0) - { - throw new ArgumentException( - "Multi action must have at least one TouchAction added before it can be performed"); - } - } - } -} \ No newline at end of file diff --git a/src/Appium.Net/Appium/MultiAction/TouchAction.cs b/src/Appium.Net/Appium/MultiAction/TouchAction.cs deleted file mode 100644 index 334b15d5..00000000 --- a/src/Appium.Net/Appium/MultiAction/TouchAction.cs +++ /dev/null @@ -1,288 +0,0 @@ -//Licensed under the Apache License, Version 2.0 (the "License"); -//you may not use this file except in compliance with the License. -//See the NOTICE file distributed with this work for additional -//information regarding copyright ownership. -//You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -//Unless required by applicable law or agreed to in writing, software -//distributed under the License is distributed on an "AS IS" BASIS, -//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//See the License for the specific language governing permissions and -//limitations under the License. - -using OpenQA.Selenium.Appium.Interfaces; -using System; -using System.Collections.Generic; -using System.Reflection; - -namespace OpenQA.Selenium.Appium.MultiTouch -{ - [Obsolete("TouchAction is deprecated, please use W3C actions instead: http://appium.io/docs/en/commands/interactions/actions/")] - public class TouchAction : ITouchAction - { - internal class Step - { - private Dictionary parameters = new Dictionary(); - - private string GetIdForElement(IWebElement el) - { - WebElement WebElement = el as WebElement; - if (WebElement != null) - return (string)typeof(WebElement).GetProperty("Id", - BindingFlags.NonPublic | - BindingFlags.Instance).GetValue(el, null); - - IWrapsElement elementWrapper = el as IWrapsElement; - if (elementWrapper != null) - return GetIdForElement(elementWrapper.WrappedElement); - - return null; - } - - public Step(string action) - { - parameters.Add("action", action); - } - - public Step AddOpt(string name, object value) - { - if (value != null) - { - if (!parameters.ContainsKey("options")) parameters.Add("options", new Dictionary()); - if (value is IWebElement) - { - string id = GetIdForElement((IWebElement) value); - ((Dictionary) this.parameters["options"]).Add(name, id); - } - else if (value is double) - { - double doubleValue = (double) value; - if (doubleValue == (int) doubleValue) - { - ((Dictionary) parameters["options"]) - .Add(name, (int) doubleValue); - } - else - { - ((Dictionary) parameters["options"]) - .Add(name, doubleValue); - } - } - else - { - ((Dictionary) parameters["options"]).Add(name, value); - } - } - return this; - } - - public Dictionary GetParameters() - { - return parameters; - } - } - - private IPerformsTouchActions TouchActionPerformer; - private List steps = new List(); - - - public TouchAction(IPerformsTouchActions touchActionPerformer) - { - this.TouchActionPerformer = touchActionPerformer; - } - - /// - /// Press at the specified location in the element until the context menu appears. - /// - /// The target element. - /// The x coordinate relative to the element. - /// The y coordinate relative to the element. - /// A self-reference to this . - public ITouchAction LongPress(IWebElement element, double? x = null, double? y = null) - { - Step longPressStep = new Step("longPress"); - longPressStep - .AddOpt("element", element) - .AddOpt("x", x) - .AddOpt("y", y); - steps.Add(longPressStep); - return this; - } - - /// - /// Press at the specified location in the element until the context menu appears. - /// - /// The target element. - /// The x coordinate relative to the element. - /// The y coordinate relative to the element. - /// A self-reference to this . - public ITouchAction LongPress(double x, double y) - { - Step longPressStep = new Step("longPress"); - longPressStep - .AddOpt("x", x) - .AddOpt("y", y); - steps.Add(longPressStep); - return this; - } - - /// - /// Move to the specified location in the element. - /// - /// The target element. - /// The x coordinate relative to the element. - /// The y coordinate relative to the element. - /// A self-reference to this . - public ITouchAction MoveTo(IWebElement element, double? x = null, double? y = null) - { - Step moveToStep = new Step("moveTo"); - moveToStep - .AddOpt("element", element) - .AddOpt("x", x) - .AddOpt("y", y); - steps.Add(moveToStep); - return this; - } - - /// - /// Move to the specified location. - /// - /// The x coordinate. - /// The y coordinate. - /// A self-reference to this . - public ITouchAction MoveTo(double x, double y) - { - Step moveToStep = new Step("moveTo"); - moveToStep - .AddOpt("x", x) - .AddOpt("y", y); - steps.Add(moveToStep); - return this; - } - - /// - /// Press at the specified location in the element. - /// - /// The target element. - /// The x coordinate relative to the element. - /// The y coordinate relative to the element. - /// A self-reference to this . - public ITouchAction Press(IWebElement element, double? x = null, double? y = null) - { - Step pressStep = new Step("press"); - pressStep - .AddOpt("element", element) - .AddOpt("x", x) - .AddOpt("y", y); - steps.Add(pressStep); - return this; - } - - /// - /// Press at the specified location. - /// - /// The x coordinate. - /// The y coordinate. - /// A self-reference to this . - public ITouchAction Press(double x, double y) - { - Step pressStep = new Step("press"); - pressStep - .AddOpt("x", x) - .AddOpt("y", y); - steps.Add(pressStep); - return this; - } - - /// - /// Release the pressure. - /// - /// A self-reference to this . - public ITouchAction Release() - { - Step releaseStep = new Step("release"); - steps.Add(releaseStep); - return this; - } - - /// - /// Tap at the specified location in the element. - /// - /// The target element. - /// The x coordinate relative to the element. - /// The y coordinate relative to the element. - /// The number of times to tap. - /// A self-reference to this . - public ITouchAction Tap(IWebElement element, double? x = null, double? y = null, long? count = null) - { - Step tapStep = new Step("tap"); - tapStep - .AddOpt("element", element) - .AddOpt("x", x) - .AddOpt("y", y) - .AddOpt("count", count); - steps.Add(tapStep); - return this; - } - - /// - /// Tap at the specified location. - /// - /// The x coordinate relative to the element. - /// The y coordinate relative to the element. - /// The number of times to tap. - /// A self-reference to this . - public ITouchAction Tap(double x, double y, long? count = null) - { - Step tapStep = new Step("tap"); - tapStep - .AddOpt("x", x) - .AddOpt("y", y) - .AddOpt("count", count); - steps.Add(tapStep); - return this; - } - - /// - /// Wait for the given duration. - /// - /// The amount of time to wait in milliseconds. - /// A self-reference to this . - public ITouchAction Wait(long? ms = null) - { - Step waitStep = new Step("wait"); - waitStep - .AddOpt("ms", ms); - steps.Add(waitStep); - return this; - } - - public List> GetParameters() - { - List> parameters = new List>(); - for (int i = 0; i < this.steps.Count; i++) - { - parameters.Add(steps[i].GetParameters()); - } - return parameters; - } - - /// - /// Cancels the Touch Action - /// - public void Cancel() - { - steps.Clear(); - } - - /// - /// Executes the Touch Action - /// - public void Perform() - { - TouchActionPerformer.PerformTouchAction(this); - } - } -} \ No newline at end of file diff --git a/test/integration/IOS/TouchActionTest.cs b/test/integration/IOS/TouchActionTest.cs deleted file mode 100644 index e4f0c6e1..00000000 --- a/test/integration/IOS/TouchActionTest.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Appium.Net.Integration.Tests.helpers; -using NUnit.Framework; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Appium.Interfaces; -using OpenQA.Selenium.Appium.MultiTouch; -using System; - -namespace Appium.Net.Integration.Tests.IOS -{ - [TestFixture] - [Obsolete("Touch Actions are deprecated")] - //TODO: remove this test once we deprecate touch actions - public class TouchActionTest - { - private AppiumDriver _driver; - - [OneTimeSetUp] - public void BeforeAll() - { - var capabilities = Caps.GetIosCaps(Apps.Get("iosTestApp")); - if (Env.ServerIsRemote()) - { - 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); - _driver.Manage().Timeouts().ImplicitWait= Env.ImplicitTimeoutSec; - } - - [OneTimeTearDown] - public void AfterEach() - { - _driver?.Quit(); - if (!Env.ServerIsRemote()) - { - AppiumServers.StopLocalService(); - } - } - - [Test] - public void SimpleActionTestCase() - { - _driver.FindElement(MobileBy.Id("TextField1")).Clear(); - _driver.FindElement(MobileBy.Id("TextField1")).SendKeys("1"); - _driver.FindElement(MobileBy.Id("TextField2")).Clear(); - _driver.FindElement(MobileBy.Id("TextField2")).SendKeys("3"); - var el = _driver.FindElement(MobileBy.AccessibilityId("ComputeSumButton")); - ITouchAction action = new TouchAction(_driver); - action.Press(el, 10, 10).Release(); - action.Perform(); - const string str = "4"; - Assert.That(_driver.FindElement(MobileBy.XPath("//*[@name = \"Answer\"]")).Text, Is.EqualTo(str)); - } - - [Test] - public void MultiActionTestCase() - { - _driver.FindElement(MobileBy.Id("TextField1")).Clear(); - _driver.FindElement(MobileBy.Id("TextField1")).SendKeys("2"); - _driver.FindElement(MobileBy.Id("TextField2")).Clear(); - _driver.FindElement(MobileBy.Id("TextField2")).SendKeys("4"); - var el = _driver.FindElement(MobileBy.AccessibilityId("ComputeSumButton")); - ITouchAction a1 = new TouchAction(_driver); - a1.Tap(el, 10, 10); - ITouchAction a2 = new TouchAction(_driver); - a2.Tap(el); - IMultiAction m = new MultiAction(_driver); - m.Add(a1).Add(a2); - m.Perform(); - const string str = "6"; - Assert.That(_driver.FindElement(MobileBy.XPath("//*[@name = \"Answer\"]")).Text, Is.EqualTo(str)); - } - } -} \ No newline at end of file