From 33b22dbb10af03dd22cfcc5f7083d3905785a5cd Mon Sep 17 00:00:00 2001 From: Manuel Blanco Date: Mon, 23 Jun 2025 22:47:49 +0200 Subject: [PATCH] refactor: replace deprecated ErrorCodes.SUCCESS_STRING with literal "success" Replaced usage of ErrorCodes.SUCCESS_STRING with the literal string "success" in ProtocolHandshake.java and RemotableByTest.java, as ErrorCodes is marked @Deprecated(forRemoval = true). Also removed direct use of ErrorCodes.SUCCESS and related methods like errorCodes.toStatusCode(e) in preparation for full W3C compliance, where status and state fields are no longer needed or recommended in responses. This change aligns the codebase with the W3C WebDriver protocol by reducing reliance on deprecated JSON Wire Protocol conventions. --- java/src/org/openqa/selenium/remote/ProtocolHandshake.java | 3 +-- java/test/org/openqa/selenium/remote/RemotableByTest.java | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/java/src/org/openqa/selenium/remote/ProtocolHandshake.java b/java/src/org/openqa/selenium/remote/ProtocolHandshake.java index f5bca85d9de82..6a3846b40b54c 100644 --- a/java/src/org/openqa/selenium/remote/ProtocolHandshake.java +++ b/java/src/org/openqa/selenium/remote/ProtocolHandshake.java @@ -178,8 +178,7 @@ public Dialect getDialect() { public Response createResponse() { Response response = new Response(sessionId); response.setValue(capabilities); - response.setStatus(ErrorCodes.SUCCESS); - response.setState(ErrorCodes.SUCCESS_STRING); + response.setState("success"); return response; } diff --git a/java/test/org/openqa/selenium/remote/RemotableByTest.java b/java/test/org/openqa/selenium/remote/RemotableByTest.java index df526e46efa0d..c9890fab3e8b4 100644 --- a/java/test/org/openqa/selenium/remote/RemotableByTest.java +++ b/java/test/org/openqa/selenium/remote/RemotableByTest.java @@ -20,7 +20,6 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.openqa.selenium.remote.ErrorCodes.SUCCESS_STRING; import com.google.common.collect.ImmutableMap; import java.util.Arrays; @@ -42,7 +41,6 @@ class RemotableByTest { private final SessionId id = new SessionId(UUID.randomUUID()); - private final ErrorCodes errorCodes = new ErrorCodes(); @Test void shouldCallW3CLocatorWithW3CParameters() { @@ -198,7 +196,7 @@ public Parameters getRemoteParameters() { private Response createResponse(Object value) { Response res = new Response(); - res.setState(SUCCESS_STRING); + res.setState("success"); res.setSessionId(id.toString()); res.setValue(value); return res; @@ -206,8 +204,7 @@ private Response createResponse(Object value) { private Response createError(Exception e) { Response res = new Response(); - res.setStatus(errorCodes.toStatusCode(e)); - res.setState(errorCodes.toState(res.getStatus())); + res.setState(res.getStatus().toString()); res.setValue(ErrorCodec.createDefault().encode(e)); return res; }