Skip to content

Commit bebcf79

Browse files
authored
Merge pull request #1 from seleniumhq-community/pr/update-to-4.23.0
Update to 4.23.0; fix test issues
2 parents f453a24 + 171f47e commit bebcf79

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

Diff for: pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
3333
<maven.compiler.source>11</maven.compiler.source>
3434
<maven.compiler.target>11</maven.compiler.target>
35-
<selenium.version>4.22.0</selenium.version>
35+
<selenium.version>4.23.0</selenium.version>
3636
<checkstyle.version>10.15.0</checkstyle.version>
3737
<spotbugs.version>4.8.4</spotbugs.version>
3838
<archunit.version>1.3.0</archunit.version>

Diff for: src/main/java/org/openqa/selenium/htmlunit/remote/JsonToHtmlUnitWebElementConverter.java

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public Object apply(Object result) {
4040
} catch (Exception e) {
4141
// nothing to do here
4242
}
43+
return result;
4344
}
4445

4546
return super.apply(result);

Diff for: src/test/java/org/openqa/selenium/htmlunit/remote/HtmlUnitDriverRemoteElementTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void shouldBeAbleToGetElementRect() throws Exception {
169169
assertEquals("Failed getting element rect", HTTP_OK, response.getStatus());
170170
Map<String, Object> elementRect = extractMap(response);
171171
assertEquals("Element width", 1256L, elementRect.get("width"));
172-
assertEquals("Element height", 72L, elementRect.get("height"));
172+
assertEquals("Element height", 54L, elementRect.get("height"));
173173
assertEquals("Element 'x' position", 5L, elementRect.get("x"));
174174
assertEquals("Element 'y' position", 5L, elementRect.get("y"));
175175
}

Diff for: src/test/java/org/openqa/selenium/htmlunit/remote/RemoteWebDriverTestCase.java

+29
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
import java.util.List;
2626
import java.util.Map;
2727

28+
import org.junit.After;
2829
import org.junit.Before;
2930
import org.openqa.selenium.Capabilities;
31+
import org.openqa.selenium.NoSuchSessionException;
3032
import org.openqa.selenium.WebDriver;
3133
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
3234
import org.openqa.selenium.htmlunit.WebDriverTestCase;
@@ -60,6 +62,18 @@ public void setUp() {
6062
sessionId = createDriverSession();
6163
}
6264

65+
@After
66+
public void cleanUp() {
67+
if (sessionId != null) {
68+
try {
69+
closeDriverSession();
70+
} catch (NoSuchSessionException e) {
71+
// nothing to do here
72+
}
73+
sessionId = null;
74+
}
75+
}
76+
6377
@Override
6478
protected WebDriver getWebDriver() {
6579
return HtmlUnitDriverServer.getDriverSession(sessionId);
@@ -92,6 +106,21 @@ private static HttpRequest newSessionRequest(final Capabilities capabilities) {
92106
return request;
93107
}
94108

109+
private void closeDriverSession() throws NoSuchSessionException {
110+
List<String> windowHandles = getWindowHandles(sessionId);
111+
while ( ! windowHandles.isEmpty()) {
112+
HttpResponse response = HtmlUnitDriverServer.closeWindow(sessionId);
113+
assertEquals("Failed closing window", HTTP_OK, response.getStatus());
114+
windowHandles = extractListOfStrings(response);
115+
}
116+
}
117+
118+
private List<String> getWindowHandles(final String sessionId) throws NoSuchSessionException {
119+
HttpResponse response = HtmlUnitDriverServer.getWindowHandles(sessionId);
120+
assertEquals("Failed getting window handles", HTTP_OK, response.getStatus());
121+
return extractListOfStrings(response);
122+
}
123+
95124
protected <T> T extractValueOfType(final HttpResponse response, final Type type) {
96125
Map<String, T> content = fromJson(response, type);
97126
assertTrue("Failed finding response value", content.containsKey("value"));

0 commit comments

Comments
 (0)