Skip to content

Commit 8c7574f

Browse files
authored
Merge pull request #7 from sbabcoc/pr/fix-standalone-grid
Fix standalone grid operation
2 parents 8523f6d + 1c0a802 commit 8c7574f

File tree

5 files changed

+86
-11
lines changed

5 files changed

+86
-11
lines changed

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.nordstrom.ui-tools</groupId>
88
<artifactId>htmlunit-remote</artifactId>
9-
<version>0.0.1-SNAPSHOT</version>
9+
<version>4.22.0-SNAPSHOT</version>
1010

1111
<name>htmlunit-remote</name>
1212

@@ -15,7 +15,7 @@
1515
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
1616
<maven.compiler.source>11</maven.compiler.source>
1717
<maven.compiler.target>11</maven.compiler.target>
18-
<selenium.version>4.21.0</selenium.version>
18+
<selenium.version>4.22.0</selenium.version>
1919
<checkstyle.version>10.15.0</checkstyle.version>
2020
<spotbugs.version>4.8.4</spotbugs.version>
2121
<archunit.version>1.3.0</archunit.version>
@@ -41,7 +41,7 @@
4141
<dependency>
4242
<groupId>org.seleniumhq.selenium</groupId>
4343
<artifactId>htmlunit3-driver</artifactId>
44-
<version>4.21.0-SNAPSHOT</version>
44+
<version>4.22.0-SNAPSHOT</version>
4545
</dependency>
4646
<dependency>
4747
<groupId>junit</groupId>
@@ -169,17 +169,17 @@
169169
<groupId>org.apache.maven.plugins</groupId>
170170
<artifactId>maven-assembly-plugin</artifactId>
171171
<version>3.7.1</version>
172+
<configuration>
173+
<descriptors>
174+
<descriptor>src/assembly/assembly.xml</descriptor>
175+
</descriptors>
176+
</configuration>
172177
<executions>
173178
<execution>
174179
<phase>package</phase>
175180
<goals>
176181
<goal>single</goal>
177182
</goals>
178-
<configuration>
179-
<descriptorRefs>
180-
<descriptorRef>jar-with-dependencies</descriptorRef>
181-
</descriptorRefs>
182-
</configuration>
183183
</execution>
184184
</executions>
185185
</plugin>

src/assembly/assembly.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd">
4+
<id>jar-with-deps</id>
5+
<formats>
6+
<format>jar</format>
7+
</formats>
8+
<includeBaseDirectory>false</includeBaseDirectory>
9+
<dependencySets>
10+
<dependencySet>
11+
<outputDirectory>/</outputDirectory>
12+
<unpack>true</unpack>
13+
<scope>runtime</scope>
14+
<includes>
15+
<include>com.nordstrom.ui-tools:htmlunit-remote</include>
16+
<include>org.seleniumhq.selenium:htmlunit3-driver</include>
17+
<include>org.htmlunit:htmlunit</include>
18+
<include>org.apache.httpcomponents:httpmime</include>
19+
<include>org.apache.httpcomponents:httpclient</include>
20+
<include>org.apache.httpcomponents:httpcore</include>
21+
<include>org.htmlunit:htmlunit-core-js</include>
22+
<include>org.htmlunit:neko-htmlunit</include>
23+
<include>org.htmlunit:htmlunit-cssparser</include>
24+
<include>org.htmlunit:htmlunit-xpath</include>
25+
<include>org.htmlunit:htmlunit-csp</include>
26+
<include>org.htmlunit:htmlunit-websocket-client</include>
27+
<include>org.apache.commons:commons-lang3</include>
28+
<include>org.apache.commons:commons-text</include>
29+
<include>commons-io:commons-io</include>
30+
<include>commons-logging:commons-logging</include>
31+
<include>commons-net:commons-net</include>
32+
<include>commons-codec:commons-codec</include>
33+
<include>org.brotli:dec</include>
34+
</includes>
35+
</dependencySet>
36+
</dependencySets>
37+
<containerDescriptorHandlers>
38+
<containerDescriptorHandler>
39+
<handlerName>metaInf-services</handlerName>
40+
</containerDescriptorHandler>
41+
</containerDescriptorHandlers>
42+
</assembly>

src/main/java/org/openqa/selenium/htmlunit/remote/HtmlUnitDriverService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.time.Duration;
2525
import java.util.List;
2626
import java.util.Map;
27+
2728
import org.openqa.selenium.Capabilities;
2829
import org.openqa.selenium.WebDriverException;
2930
import org.openqa.selenium.grid.config.MapConfig;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.openqa.selenium.htmlunit.remote;
2+
3+
import java.io.Serializable;
4+
import org.openqa.selenium.Capabilities;
5+
import org.openqa.selenium.grid.data.SlotMatcher;
6+
import org.openqa.selenium.remote.Browser;
7+
8+
public class HtmlUnitSlotMatcher implements SlotMatcher, Serializable {
9+
10+
private static final long serialVersionUID = 1L;
11+
12+
@Override
13+
public boolean matches(Capabilities stereotype, Capabilities capabilities) {
14+
15+
if (capabilities.asMap().isEmpty()) {
16+
return false;
17+
}
18+
19+
if (!managedDownloadsEnabled(stereotype, capabilities)) {
20+
return false;
21+
}
22+
23+
return Browser.HTMLUNIT.is(capabilities);
24+
}
25+
26+
private Boolean managedDownloadsEnabled(Capabilities stereotype, Capabilities capabilities) {
27+
if (!Boolean.parseBoolean(String.valueOf(capabilities.getCapability("se:downloadsEnabled")))) {
28+
return true;
29+
}
30+
return Boolean.parseBoolean(String.valueOf(stereotype.getCapability("se:downloadsEnabled")));
31+
}
32+
}

src/test/java/org/openqa/selenium/htmlunit/remote/HtmlUnitDriverRemoteContextTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public void shouldBeAbleToGetWindowRect() {
147147
assertEquals("Failed getting window rect", HTTP_OK, response.getStatus());
148148
Map<String, Object> windowRect = extractMap(response);
149149
assertEquals("Window width", 1272L, windowRect.get("width"));
150-
assertEquals("Window height", 753L, windowRect.get("height"));
150+
assertEquals("Window height", 752L, windowRect.get("height"));
151151
assertEquals("Window 'x' position", 0L, windowRect.get("x"));
152152
assertEquals("Window 'y' position", 0L, windowRect.get("y"));
153153
}
@@ -172,7 +172,7 @@ public void shouldBeAbleToMaximizeWindow() {
172172
assertEquals("Failed maximizing window", HTTP_OK, response.getStatus());
173173
Map<String, Object> windowRect = extractMap(response);
174174
assertEquals("Window width", 1272L, windowRect.get("width"));
175-
assertEquals("Window height", 753L, windowRect.get("height"));
175+
assertEquals("Window height", 752L, windowRect.get("height"));
176176
assertEquals("Window 'x' position", 0L, windowRect.get("x"));
177177
assertEquals("Window 'y' position", 0L, windowRect.get("y"));
178178
}
@@ -183,7 +183,7 @@ public void shouldBeAbleToFullscreenWindow() {
183183
assertEquals("Failed maximizing window", HTTP_OK, response.getStatus());
184184
Map<String, Object> windowRect = extractMap(response);
185185
assertEquals("Window width", 1272L, windowRect.get("width"));
186-
assertEquals("Window height", 753L, windowRect.get("height"));
186+
assertEquals("Window height", 752L, windowRect.get("height"));
187187
assertEquals("Window 'x' position", 0L, windowRect.get("x"));
188188
assertEquals("Window 'y' position", 0L, windowRect.get("y"));
189189
}

0 commit comments

Comments
 (0)