diff --git a/dotnet/src/webdriver/Response.cs b/dotnet/src/webdriver/Response.cs index c6ac73328b1d7..b313c16513872 100644 --- a/dotnet/src/webdriver/Response.cs +++ b/dotnet/src/webdriver/Response.cs @@ -20,6 +20,7 @@ using OpenQA.Selenium.Internal; using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; @@ -215,6 +216,21 @@ public string ToJson() return JsonSerializer.Serialize(this); } + /// + /// Throws if is . + /// + /// If is . + [MemberNotNull(nameof(Value))] + internal Response EnsureValueIsNotNull() + { + if (Value is null) + { + throw new WebDriverException("Response from remote end doesn't have $.Value property"); + } + + return this; + } + /// /// Returns the object as a string. ///