Skip to content

Commit

Permalink
[java] Convert RemoteWebElement::getLocation and ::getSize from JWP S…
Browse files Browse the repository at this point in the history
…tandard to W3C Standard (#10700)

* [Java] Convert RemoteWebElement::getLocation and ::getSize from JWP Standard to W3C Standard

Fixes #10698 as part of #10374

* [java] Fixing RemoteWebElementTest unit tests

Co-authored-by: Diego Molina <diemol@users.noreply.github.com>
Co-authored-by: Diego Molina <diemol@gmail.com>

[skip ci]
  • Loading branch information
BJap authored May 27, 2022
1 parent c0d25bc commit eda884a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions java/src/org/openqa/selenium/remote/RemoteWebElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public boolean isDisplayed() {
@Override
@SuppressWarnings({"unchecked"})
public Point getLocation() {
Response response = execute(DriverCommand.GET_ELEMENT_LOCATION(id));
Response response = execute(DriverCommand.GET_ELEMENT_RECT(id));
Map<String, Object> rawPoint = (Map<String, Object>) response.getValue();
int x = ((Number) rawPoint.get("x")).intValue();
int y = ((Number) rawPoint.get("y")).intValue();
Expand All @@ -336,7 +336,7 @@ public Point getLocation() {
@Override
@SuppressWarnings({"unchecked"})
public Dimension getSize() {
Response response = execute(DriverCommand.GET_ELEMENT_SIZE(id));
Response response = execute(DriverCommand.GET_ELEMENT_RECT(id));
Map<String, Object> rawSize = (Map<String, Object>) response.getValue();
int width = ((Number) rawSize.get("width")).intValue();
int height = ((Number) rawSize.get("height")).intValue();
Expand Down
24 changes: 12 additions & 12 deletions java/test/org/openqa/selenium/remote/RemoteWebElementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@

package org.openqa.selenium.remote;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
import static org.openqa.selenium.remote.WebDriverFixture.echoCapabilities;
import static org.openqa.selenium.remote.WebDriverFixture.errorResponder;
import static org.openqa.selenium.remote.WebDriverFixture.exceptionResponder;
import static org.openqa.selenium.remote.WebDriverFixture.nullValueResponder;
import static org.openqa.selenium.remote.WebDriverFixture.valueResponder;
import static org.openqa.selenium.remote.WebDriverFixture.webDriverExceptionResponder;

import com.google.common.collect.ImmutableMap;

import org.junit.Test;
Expand All @@ -40,6 +30,16 @@
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.testing.UnitTests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
import static org.openqa.selenium.remote.WebDriverFixture.echoCapabilities;
import static org.openqa.selenium.remote.WebDriverFixture.errorResponder;
import static org.openqa.selenium.remote.WebDriverFixture.exceptionResponder;
import static org.openqa.selenium.remote.WebDriverFixture.nullValueResponder;
import static org.openqa.selenium.remote.WebDriverFixture.valueResponder;
import static org.openqa.selenium.remote.WebDriverFixture.webDriverExceptionResponder;

@Category(UnitTests.class)
public class RemoteWebElementTest {

Expand Down Expand Up @@ -298,7 +298,7 @@ public void canHandleGetLocationCommand() {
assertThat(fixture.element.getLocation()).isEqualTo(new Point(10, 20));

fixture.verifyCommands(
new CommandPayload(DriverCommand.GET_ELEMENT_LOCATION,
new CommandPayload(DriverCommand.GET_ELEMENT_RECT,
ImmutableMap.of("id", fixture.element.getId())));
}

Expand All @@ -311,7 +311,7 @@ public void canHandleGetSizeCommand() {

fixture.verifyCommands(
new CommandPayload(
DriverCommand.GET_ELEMENT_SIZE, ImmutableMap.of("id", fixture.element.getId())));
DriverCommand.GET_ELEMENT_RECT, ImmutableMap.of("id", fixture.element.getId())));
}

@Test
Expand Down

0 comments on commit eda884a

Please sign in to comment.