Skip to content

Commit 2570c3d

Browse files
[dotnet] Fix nullability annotations on NodeRemoteValue (#16661)
* [dotnet] Fix nullability annotations on `NodeRemoteValue` * [dotnet] Improve test for SharedId
1 parent e633bc2 commit 2570c3d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

dotnet/src/webdriver/BiDi/Script/RemoteValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public sealed record HtmlCollectionRemoteValue : RemoteValue
252252
public IReadOnlyList<RemoteValue>? Value { get; set; }
253253
}
254254

255-
public sealed record NodeRemoteValue(string? SharedId, NodeProperties? Value) : RemoteValue, ISharedReference
255+
public sealed record NodeRemoteValue(string SharedId, NodeProperties? Value) : RemoteValue, ISharedReference
256256
{
257257
public Handle? Handle { get; set; }
258258

dotnet/test/common/BiDi/Script/CallFunctionParameterTest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using NUnit.Framework;
21+
using System.Runtime.CompilerServices;
2122
using System.Threading.Tasks;
2223

2324
namespace OpenQA.Selenium.BiDi.Script;
@@ -104,7 +105,10 @@ public async Task CanCallFunctionToGetElement()
104105

105106
Assert.That(res, Is.Not.Null);
106107
Assert.That(res.AsSuccessResult(), Is.AssignableFrom<NodeRemoteValue>());
107-
Assert.That((res.AsSuccessResult() as NodeRemoteValue).Value, Is.Not.Null);
108+
109+
var node = (NodeRemoteValue)res.AsSuccessResult();
110+
Assert.That(node.Value, Is.Not.Null);
111+
Assert.That(node.SharedId, Is.EqualTo(GetElementId(By.Id("consoleLog"))));
108112
}
109113

110114
[Test]
@@ -219,4 +223,13 @@ public async Task CanCallFunctionInARealm()
219223
Assert.That(res1, Is.EqualTo(3));
220224
Assert.That(res2, Is.EqualTo(5));
221225
}
226+
227+
private string GetElementId(By selector)
228+
{
229+
var element = (WebElement)driver.FindElement(selector);
230+
return ReflectElementId(element);
231+
232+
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = "get_Id")]
233+
static extern string ReflectElementId(WebElement element);
234+
}
222235
}

0 commit comments

Comments
 (0)