diff --git a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
index 85921d73954be..d8a44d46e2149 100644
--- a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
+++ b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
@@ -340,7 +340,8 @@ private Response CreateResponse(HttpResponseInfo responseInfo)
if (response.Value is string valueString)
{
- response.Value = valueString.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);
+ valueString = valueString.Replace("\r\n", "\n").Replace("\n", Environment.NewLine);
+ response = new Response(response.SessionId, valueString, response.Status);
}
return response;
diff --git a/dotnet/src/webdriver/Response.cs b/dotnet/src/webdriver/Response.cs
index 9a0de908859a5..c6ac73328b1d7 100644
--- a/dotnet/src/webdriver/Response.cs
+++ b/dotnet/src/webdriver/Response.cs
@@ -42,6 +42,7 @@ public class Response
///
/// Initializes a new instance of the class
///
+ [Obsolete("Set all values using the Response(string, object, WebDriverResult) constructor instead. This constructor will be removed in Selenium 4.30")]
public Response()
{
}
@@ -50,6 +51,7 @@ public Response()
/// Initializes a new instance of the class
///
/// Session ID in use
+ [Obsolete("Set all values using the Response(string, object, WebDriverResult) constructor instead. This constructor will be removed in Selenium 4.30")]
public Response(SessionId? sessionId)
{
this.SessionId = sessionId?.ToString();
@@ -136,18 +138,35 @@ public static Response FromJson(string value)
///
/// Gets or sets the value from JSON.
///
- public object? Value { get; set; }
+ public object? Value
+ {
+ get;
+
+ [Obsolete("The Response type will be immutable and this setter will be removed in Selenium 4.30")]
+ set;
+ }
///
/// Gets or sets the session ID.
///
- public string? SessionId { get; set; }
+ public string? SessionId
+ {
+ get;
+
+ [Obsolete("The Response type will be immutable and this setter will be removed in Selenium 4.30")]
+ set;
+ }
///
/// Gets or sets the status value of the response.
///
- public WebDriverResult Status { get; set; }
+ public WebDriverResult Status
+ {
+ get;
+ [Obsolete("The Response type will be immutable and this setter will be removed in Selenium 4.30")]
+ set;
+ }
///
/// Returns a new from a JSON-encoded string.