Skip to content

Commit

Permalink
Revert WheelInputDevice.ConvertElement and `PointerInputDevice.Conv…
Browse files Browse the repository at this point in the history
…ertElement`
  • Loading branch information
RenderMichael committed Dec 2, 2024
1 parent 8f7180d commit 2432a51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
18 changes: 12 additions & 6 deletions dotnet/src/webdriver/Interactions/PointerInputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.Internal;
using System;
using System.Collections.Generic;
using System.Globalization;
using OpenQA.Selenium.Internal;

#nullable enable

Expand Down Expand Up @@ -582,17 +582,23 @@ public override string ToString()

private Dictionary<string, object> 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<string, object> elementDictionary = elementReference.ToDictionary();
return elementDictionary;
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions dotnet/src/webdriver/Interactions/WheelInputDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// under the License.
// </copyright>

using OpenQA.Selenium.Internal;
using System;
using System.Collections.Generic;
using OpenQA.Selenium.Internal;

#nullable enable

Expand Down Expand Up @@ -203,17 +203,23 @@ public override Dictionary<string, object> ToDictionary()

private Dictionary<string, object> 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<string, object> elementDictionary = elementReference.ToDictionary();
return elementDictionary;
}
}
}
Expand Down

0 comments on commit 2432a51

Please sign in to comment.