Skip to content

Commit 18f9b95

Browse files
committed
Marking .NET hardware manipulation interfaces deprecated
The `Mouse`, `Keyboard`, and `TouchScreen` properties were never intended for direct use in users' code. These interfaces, and the properties that reference them, are now being marked as deprecated. The correct way to simulate advanced user input is to use the `Actions` or `ActionBuilder` classes.
1 parent 6bb3e14 commit 18f9b95

7 files changed

Lines changed: 20 additions & 11 deletions

File tree

dotnet/src/webdriver/IHasInputDevices.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="IHasInputDevices.cs" company="WebDriver Committers">
1+
// <copyright file="IHasInputDevices.cs" company="WebDriver Committers">
22
// Licensed to the Software Freedom Conservancy (SFC) under one
33
// or more contributor license agreements. See the NOTICE file
44
// distributed with this work for additional information
@@ -16,11 +16,14 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using System;
20+
1921
namespace OpenQA.Selenium
2022
{
2123
/// <summary>
2224
/// Provides access to input devices for advanced user interactions.
2325
/// </summary>
26+
[Obsolete("Use the Actions or ActionBuilder class to simulate mouse and keyboard input.")]
2427
public interface IHasInputDevices
2528
{
2629
/// <summary>

dotnet/src/webdriver/IHasTouchScreen.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="IHasTouchScreen.cs" company="WebDriver Committers">
1+
// <copyright file="IHasTouchScreen.cs" company="WebDriver Committers">
22
// Licensed to the Software Freedom Conservancy (SFC) under one
33
// or more contributor license agreements. See the NOTICE file
44
// distributed with this work for additional information
@@ -16,11 +16,14 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using System;
20+
1921
namespace OpenQA.Selenium
2022
{
2123
/// <summary>
2224
/// Interface implemented by each driver that allows access to touch screen capabilities.
2325
/// </summary>
26+
[Obsolete("Use the TouchActions or ActionBuilder class to simulate touch input.")]
2427
public interface IHasTouchScreen
2528
{
2629
/// <summary>

dotnet/src/webdriver/IKeyboard.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="IKeyboard.cs" company="WebDriver Committers">
1+
// <copyright file="IKeyboard.cs" company="WebDriver Committers">
22
// Licensed to the Software Freedom Conservancy (SFC) under one
33
// or more contributor license agreements. See the NOTICE file
44
// distributed with this work for additional information
@@ -16,11 +16,14 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using System;
20+
1921
namespace OpenQA.Selenium
2022
{
2123
/// <summary>
2224
/// Provides methods representing basic keyboard actions.
2325
/// </summary>
26+
[Obsolete("Use the Actions or ActionBuilder class to simulate keyboard input.")]
2427
public interface IKeyboard
2528
{
2629
/// <summary>

dotnet/src/webdriver/IMouse.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="IMouse.cs" company="WebDriver Committers">
1+
// <copyright file="IMouse.cs" company="WebDriver Committers">
22
// Licensed to the Software Freedom Conservancy (SFC) under one
33
// or more contributor license agreements. See the NOTICE file
44
// distributed with this work for additional information
@@ -16,13 +16,15 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using System;
1920
using OpenQA.Selenium.Interactions.Internal;
2021

2122
namespace OpenQA.Selenium
2223
{
2324
/// <summary>
2425
/// Provides methods representing basic mouse actions.
2526
/// </summary>
27+
[Obsolete("Use the Actions or ActionBuilder class to simulate mouse input.")]
2628
public interface IMouse
2729
{
2830
/// <summary>

dotnet/src/webdriver/ITouchScreen.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// <copyright file="ITouchScreen.cs" company="WebDriver Committers">
1+
// <copyright file="ITouchScreen.cs" company="WebDriver Committers">
22
// Licensed to the Software Freedom Conservancy (SFC) under one
33
// or more contributor license agreements. See the NOTICE file
44
// distributed with this work for additional information
@@ -17,12 +17,14 @@
1717
// </copyright>
1818

1919
using OpenQA.Selenium.Interactions.Internal;
20+
using System;
2021

2122
namespace OpenQA.Selenium
2223
{
2324
/// <summary>
2425
/// Interface representing basic touch screen operations.
2526
/// </summary>
27+
[Obsolete("Use the TouchActions or ActionBuilder class to simulate touch input.")]
2628
public interface ITouchScreen
2729
{
2830
/// <summary>

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public ReadOnlyCollection<string> WindowHandles
261261
/// <summary>
262262
/// Gets an <see cref="IKeyboard"/> object for sending keystrokes to the browser.
263263
/// </summary>
264+
[Obsolete("This property was never intended to be used in user code. Use the Actions or ActionBuilder class to send direct keyboard input.")]
264265
public IKeyboard Keyboard
265266
{
266267
get { return this.keyboard; }
@@ -269,6 +270,7 @@ public IKeyboard Keyboard
269270
/// <summary>
270271
/// Gets an <see cref="IMouse"/> object for sending mouse commands to the browser.
271272
/// </summary>
273+
[Obsolete("This property was never intended to be used in user code. Use the Actions or ActionBuilder class to send direct mouse input.")]
272274
public IMouse Mouse
273275
{
274276
get { return this.mouse; }

dotnet/test/common/Interactions/BasicMouseInterfaceTest.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,6 @@ public void ShouldAllowUsersToHoverOverElements()
242242
Assert.Ignore("Skipping test: Simulating hover needs native events");
243243
}
244244

245-
IHasInputDevices inputDevicesDriver = driver as IHasInputDevices;
246-
if (inputDevicesDriver == null)
247-
{
248-
return;
249-
}
250-
251245
IWebElement item = driver.FindElement(By.Id("item1"));
252246
Assert.AreEqual("", item.Text);
253247

0 commit comments

Comments
 (0)