From 3b3a3edf36a7a2871b1aeac6cba60ec2bd4960e1 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Fri, 24 Jun 2022 11:47:56 -0500 Subject: [PATCH] [dotnet] remove obsolete TouchActions class --- dotnet/src/webdriver/DriverCommand.cs | 48 ----- .../webdriver/Interactions/TouchActions.cs | 189 ------------------ dotnet/src/webdriver/WebDriver.csproj | 1 + 3 files changed, 1 insertion(+), 237 deletions(-) delete mode 100644 dotnet/src/webdriver/Interactions/TouchActions.cs diff --git a/dotnet/src/webdriver/DriverCommand.cs b/dotnet/src/webdriver/DriverCommand.cs index 41eed978e662c..91d5fe4a30b54 100644 --- a/dotnet/src/webdriver/DriverCommand.cs +++ b/dotnet/src/webdriver/DriverCommand.cs @@ -481,54 +481,6 @@ public static class DriverCommand [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] public static readonly string SendKeysToActiveElement = "sendKeysToActiveElement"; - /// - /// Represents the TouchSingleTap command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchSingleTap = "touchSingleTap"; - - /// - /// Represents the TouchPress command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchPress = "touchDown"; - - /// - /// Represents the TouchRelease command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchRelease = "touchUp"; - - /// - /// Represents the TouchMove command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchMove = "touchMove"; - - /// - /// Represents the TouchScroll command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchScroll = "touchScroll"; - - /// - /// Represents the TouchDoubleTap command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchDoubleTap = "touchDoubleTap"; - - /// - /// Represents the TouchLongPress command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchLongPress = "touchLongPress"; - - /// - /// Represents the TouchFlick command. - /// - [Obsolete("Command not defined by W3C WebDriver Specification. Use the actions command to define user interactions.")] - public static readonly string TouchFlick = "touchFlick"; - /// /// Represents the Authenticate command /// diff --git a/dotnet/src/webdriver/Interactions/TouchActions.cs b/dotnet/src/webdriver/Interactions/TouchActions.cs deleted file mode 100644 index c2b0e19558d08..0000000000000 --- a/dotnet/src/webdriver/Interactions/TouchActions.cs +++ /dev/null @@ -1,189 +0,0 @@ -// -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// 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 OpenQA.Selenium.Internal; - -namespace OpenQA.Selenium.Interactions -{ - /// - /// Provides a mechanism for building advanced interactions with the browser. - /// - public class TouchActions : Actions - { - private readonly TimeSpan DefaultScrollMoveDuration = TimeSpan.FromSeconds(2); - private readonly TimeSpan DefaultLongPressDuration = TimeSpan.FromSeconds(2); - private readonly TimeSpan DefaultFlickDuration = TimeSpan.FromMilliseconds(100); - private ActionBuilder actionBuilder = new ActionBuilder(); - private PointerInputDevice defaultTouchscreen = new PointerInputDevice(PointerKind.Touch, "default touch pointer"); - - /// - /// Initializes a new instance of the class. - /// - /// The object on which the actions built will be performed. - public TouchActions(IWebDriver driver) - : base(driver) - { - } - - /// - /// Taps the touch screen on the specified element. - /// - /// The element on which to tap. - /// A self-reference to this . - public TouchActions SingleTap(IWebElement onElement) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(onElement, 0, 0, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Presses down at the specified location on the screen. - /// - /// The x coordinate relative to the view port. - /// The y coordinate relative to the view port. - /// A self-reference to this . - public TouchActions Down(int locationX, int locationY) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, locationX, locationY, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - return this; - } - - /// - /// Releases a press at the specified location on the screen. - /// - /// The x coordinate relative to the view port. - /// The y coordinate relative to the view port. - /// A self-reference to this . - public TouchActions Up(int locationX, int locationY) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, locationX, locationY, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Moves to the specified location on the screen. - /// - /// The x coordinate relative to the view port. - /// The y coordinate relative to the view port. - /// A self-reference to this . - public TouchActions Move(int locationX, int locationY) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, locationX, locationY, TimeSpan.Zero)); - return this; - } - - /// - /// Scrolls the touch screen beginning at the specified element. - /// - /// The element on which to begin scrolling. - /// The x coordinate relative to the view port. - /// The y coordinate relative to the view port. - /// A self-reference to this . - public TouchActions Scroll(IWebElement onElement, int offsetX, int offsetY) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(onElement, 0, 0, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, offsetX, offsetX, DefaultScrollMoveDuration)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Double-taps the touch screen on the specified element. - /// - /// The element on which to double-tap. - /// A self-reference to this . - public TouchActions DoubleTap(IWebElement onElement) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(onElement, 0, 0, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Presses and holds on the touch screen on the specified element. - /// - /// The element on which to press and hold - /// A self-reference to this . - public TouchActions LongPress(IWebElement onElement) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(onElement, 0, 0, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePause(DefaultLongPressDuration)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Scrolls the touch screen to the specified offset. - /// - /// The horizontal offset relative to the view port. - /// The vertical offset relative to the view port. - /// A self-reference to this . - public TouchActions Scroll(int offsetX, int offsetY) - { - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, offsetX, offsetX, DefaultScrollMoveDuration)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Flicks the current view. - /// - /// The horizontal speed in pixels per second. - /// The vertical speed in pixels per second. - /// A self-reference to this . - public TouchActions Flick(int speedX, int speedY) - { - int offsetX = Convert.ToInt32(Math.Round(speedX * DefaultFlickDuration.TotalSeconds, 0)); - int offsetY = Convert.ToInt32(Math.Round(speedY * DefaultFlickDuration.TotalSeconds, 0)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, offsetX, offsetY, DefaultFlickDuration)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - - /// - /// Flicks the current view starting at a specific location. - /// - /// The element at which to start the flick. - /// The x offset relative to the viewport. - /// The y offset relative to the viewport. - /// The speed in pixels per second. - /// A self-reference to this . - public TouchActions Flick(IWebElement onElement, int offsetX, int offsetY, int speed) - { - int normalizedOffsetX = Convert.ToInt32(offsetX / speed * DefaultFlickDuration.TotalSeconds); - int normalizedOffsetY = Convert.ToInt32(offsetY / speed * DefaultFlickDuration.TotalSeconds); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(onElement, 0, 0, TimeSpan.Zero)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerDown(MouseButton.Touch)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerMove(CoordinateOrigin.Viewport, normalizedOffsetX, normalizedOffsetY, DefaultFlickDuration)); - this.actionBuilder.AddAction(this.defaultTouchscreen.CreatePointerUp(MouseButton.Touch)); - return this; - } - } -} diff --git a/dotnet/src/webdriver/WebDriver.csproj b/dotnet/src/webdriver/WebDriver.csproj index 3b14647e9141b..16a7fffe4c8e9 100644 --- a/dotnet/src/webdriver/WebDriver.csproj +++ b/dotnet/src/webdriver/WebDriver.csproj @@ -95,6 +95,7 @@ +