diff --git a/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java b/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java index dccb9eb0e7339..ad43ee1d5a91c 100644 --- a/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java +++ b/java/src/org/openqa/selenium/devtools/CdpClientGenerator.java @@ -913,18 +913,23 @@ public TypeDeclaration toTypeDeclaration() { fromJson.getBody().get().addStatement(String.format("return new %s(%s);", name, getMapper())); MethodDeclaration toJson = classDecl.addMethod("toJson").setPublic(true); - if (type.equals("object")) { - toJson.setType("java.util.Map"); - toJson.getBody().get().addStatement(String.format("return %s;", propertyName)); - } else if (type.equals("number")) { - toJson.setType(Number.class); - toJson.getBody().get().addStatement(String.format("return %s;", propertyName)); - } else if (type.equals("integer")) { - toJson.setType(Integer.class); - toJson.getBody().get().addStatement(String.format("return %s;", propertyName)); - } else { - toJson.setType(String.class); - toJson.getBody().get().addStatement(String.format("return %s.toString();", propertyName)); + switch (type) { + case "object": + toJson.setType("java.util.Map"); + toJson.getBody().get().addStatement(String.format("return %s;", propertyName)); + break; + case "number": + toJson.setType(Number.class); + toJson.getBody().get().addStatement(String.format("return %s;", propertyName)); + break; + case "integer": + toJson.setType(Integer.class); + toJson.getBody().get().addStatement(String.format("return %s;", propertyName)); + break; + default: + toJson.setType(String.class); + toJson.getBody().get().addStatement(String.format("return %s.toString();", propertyName)); + break; } MethodDeclaration toString = classDecl.addMethod("toString").setPublic(true); diff --git a/java/src/org/openqa/selenium/support/AbstractFindByBuilder.java b/java/src/org/openqa/selenium/support/AbstractFindByBuilder.java index 791e982ed59c8..645d17dafa5c7 100644 --- a/java/src/org/openqa/selenium/support/AbstractFindByBuilder.java +++ b/java/src/org/openqa/selenium/support/AbstractFindByBuilder.java @@ -109,7 +109,7 @@ protected void assertValidFindBy(FindBy findBy) { throw new IllegalArgumentException( String.format( "You must specify at most one location strategy. Number found: %d (%s)", - finders.size(), finders.toString())); + finders.size(), finders)); } } diff --git a/java/src/org/openqa/selenium/support/Color.java b/java/src/org/openqa/selenium/support/Color.java index 60c4da53ee439..0c772ab7cd9b8 100644 --- a/java/src/org/openqa/selenium/support/Color.java +++ b/java/src/org/openqa/selenium/support/Color.java @@ -116,7 +116,7 @@ public int hashCode() { result = 31 * result + green; result = 31 * result + blue; temp = alpha != +0.0d ? Double.doubleToLongBits(alpha) : 0L; - result = 31 * result + (int) (temp ^ (temp >>> 32)); + result = 31 * result + Long.hashCode(temp); return result; } diff --git a/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java b/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java index f21609d0dc771..f9ac975f2995b 100644 --- a/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java +++ b/java/test/org/openqa/selenium/bidi/input/DefaultMouseTest.java @@ -481,7 +481,7 @@ public void testCanMoveOverAndOutOfAnElement() { inputModule.perform( windowHandle, getBuilder(driver) - .moveToElement(redbox, redSize.getWidth() / 1 + 1, redSize.getHeight() / 1 + 1) + .moveToElement(redbox, redSize.getWidth() + 1, redSize.getHeight() + 1) .getSequences()); wait.until(attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba())); diff --git a/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java b/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java index f6568f29c98eb..425aecf3133b0 100644 --- a/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java +++ b/java/test/org/openqa/selenium/bidi/input/DragAndDropTest.java @@ -57,7 +57,7 @@ private static void sleep(int ms) { try { Thread.sleep(ms); } catch (InterruptedException e) { - throw new RuntimeException("Interrupted: " + e.toString()); + throw new RuntimeException("Interrupted: " + e); } } diff --git a/java/test/org/openqa/selenium/interactions/DefaultMouseTest.java b/java/test/org/openqa/selenium/interactions/DefaultMouseTest.java index 1649713b4579a..00b00471a6833 100644 --- a/java/test/org/openqa/selenium/interactions/DefaultMouseTest.java +++ b/java/test/org/openqa/selenium/interactions/DefaultMouseTest.java @@ -404,7 +404,7 @@ public void testCanMoveOverAndOutOfAnElement() { .isEqualTo(RED.getColorValue()); getBuilder(driver) - .moveToElement(redbox, redSize.getWidth() / 1 + 1, redSize.getHeight() / 1 + 1) + .moveToElement(redbox, redSize.getWidth() + 1, redSize.getHeight() + 1) .perform(); wait.until(attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba())); diff --git a/java/test/org/openqa/selenium/interactions/PenPointerTest.java b/java/test/org/openqa/selenium/interactions/PenPointerTest.java index ad26947242920..1dcb6affdcaf1 100644 --- a/java/test/org/openqa/selenium/interactions/PenPointerTest.java +++ b/java/test/org/openqa/selenium/interactions/PenPointerTest.java @@ -367,7 +367,7 @@ public void testCanMoveOverAndOutOfAnElement() { .isEqualTo(RED.getColorValue()); setDefaultPen(driver) - .moveToElement(redbox, redSize.getWidth() / 1 + 1, redSize.getHeight() / 1 + 1) + .moveToElement(redbox, redSize.getWidth() + 1, redSize.getHeight() + 1) .perform(); wait.until(attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba())); @@ -407,8 +407,8 @@ public void setPointerEventProperties() { Rectangle rect = pointerArea.getRect(); - int centerX = (int) Math.floor(rect.width / 2 + rect.getX()); - int centerY = (int) Math.floor(rect.height / 2 + rect.getY()); + int centerX = rect.width / 2 + rect.getX(); + int centerY = rect.height / 2 + rect.getY(); Assertions.assertThat(moveTo.get("button")).isEqualTo("-1"); Assertions.assertThat(moveTo.get("pageX")).isEqualTo("" + centerX); Assertions.assertThat(moveTo.get("pageY")).isEqualTo("" + centerY);