From 2432a515970ef8f913943f01765afa131b4ae4f8 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 2 Dec 2024 13:11:29 -0500 Subject: [PATCH] Revert `WheelInputDevice.ConvertElement` and `PointerInputDevice.ConvertElement` --- .../Interactions/PointerInputDevice.cs | 18 ++++++++++++------ .../webdriver/Interactions/WheelInputDevice.cs | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/dotnet/src/webdriver/Interactions/PointerInputDevice.cs b/dotnet/src/webdriver/Interactions/PointerInputDevice.cs index 5979dbaa00f99..b8d48b25f3251 100644 --- a/dotnet/src/webdriver/Interactions/PointerInputDevice.cs +++ b/dotnet/src/webdriver/Interactions/PointerInputDevice.cs @@ -17,10 +17,10 @@ // under the License. // +using OpenQA.Selenium.Internal; using System; using System.Collections.Generic; using System.Globalization; -using OpenQA.Selenium.Internal; #nullable enable @@ -582,17 +582,23 @@ public override string ToString() private Dictionary ConvertElement() { - if (this.target is IWebDriverObjectReference element) + IWebDriverObjectReference? elementReference = this.target as IWebDriverObjectReference; + if (elementReference == null) { - return element.ToDictionary(); + IWrapsElement? elementWrapper = this.target as IWrapsElement; + if (elementWrapper != null) + { + elementReference = elementWrapper.WrappedElement as IWebDriverObjectReference; + } } - if (this.target is IWrapsElement { WrappedElement: IWebDriverObjectReference wrappedElement }) + if (elementReference == null) { - return wrappedElement.ToDictionary(); + throw new ArgumentException("Target element cannot be converted to IWebElementReference"); } - throw new ArgumentException("Target element cannot be converted to IWebElementReference"); + Dictionary elementDictionary = elementReference.ToDictionary(); + return elementDictionary; } } } diff --git a/dotnet/src/webdriver/Interactions/WheelInputDevice.cs b/dotnet/src/webdriver/Interactions/WheelInputDevice.cs index 39ac416121b78..c3e049a290ee0 100644 --- a/dotnet/src/webdriver/Interactions/WheelInputDevice.cs +++ b/dotnet/src/webdriver/Interactions/WheelInputDevice.cs @@ -17,9 +17,9 @@ // under the License. // +using OpenQA.Selenium.Internal; using System; using System.Collections.Generic; -using OpenQA.Selenium.Internal; #nullable enable @@ -203,17 +203,23 @@ public override Dictionary ToDictionary() private Dictionary ConvertElement() { - if (this.target is IWebDriverObjectReference element) + IWebDriverObjectReference? elementReference = this.target as IWebDriverObjectReference; + if (elementReference == null) { - return element.ToDictionary(); + IWrapsElement? elementWrapper = this.target as IWrapsElement; + if (elementWrapper != null) + { + elementReference = elementWrapper.WrappedElement as IWebDriverObjectReference; + } } - if (this.target is IWrapsElement { WrappedElement: IWebDriverObjectReference wrappedElement }) + if (elementReference == null) { - return wrappedElement.ToDictionary(); + throw new ArgumentException("Target element cannot be converted to IWebElementReference"); } - throw new ArgumentException("Target element cannot be converted to IWebElementReference"); + Dictionary elementDictionary = elementReference.ToDictionary(); + return elementDictionary; } } }