Skip to content

Commit 4f76ec6

Browse files
committed
Switching grid tests from chrome to htmlunit
1 parent a511341 commit 4f76ec6

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

java/server/test/org/openqa/grid/e2e/misc/GridDistributionTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void prepare() throws Exception {
5454
SelfRegisteringRemote remote =
5555
GridTestHelper.getRemoteWithoutCapabilities(hub, GridRole.NODE);
5656

57-
remote.addBrowser(DesiredCapabilities.chrome(), 3);
57+
remote.addBrowser(DesiredCapabilities.htmlUnit(), 3);
5858
remote.setRemoteServer(new SeleniumServer(remote.getConfiguration()));
5959
remote.startRemoteServer();
6060
remote.sendRegistrationRequest();
@@ -66,7 +66,7 @@ public void prepare() throws Exception {
6666
@Ignore("Times out")
6767
public void testLoadIsDistributedEvenly() throws MalformedURLException {
6868
for (int i=0; i < 8; i++) {
69-
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
69+
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.htmlUnit(), hub));
7070
}
7171

7272
ProxySet ps = hub.getRegistry().getAllProxies();
@@ -82,7 +82,7 @@ public void testLoadIsDistributedEvenly() throws MalformedURLException {
8282
}
8383

8484
for (int i=0; i < 8; i++) {
85-
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
85+
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.htmlUnit(), hub));
8686
}
8787

8888
for (RemoteProxy p : ps) {
@@ -95,7 +95,7 @@ public void testLoadIsDistributedEvenly() throws MalformedURLException {
9595
Assert.assertEquals("checking proxy free slots, all should have two sessions running", freeslots, 1);
9696
}
9797

98-
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
98+
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.htmlUnit(), hub));
9999

100100
Boolean foundOneFull = false;
101101
for (RemoteProxy p : ps) {
@@ -121,7 +121,7 @@ public void testLeastRecentlyUsedNodesPickedFirst() throws Throwable {
121121
ProxySet ps = hub.getRegistry().getAllProxies();
122122

123123
for (int i=0; i < 4; i++) {
124-
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
124+
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.htmlUnit(), hub));
125125
}
126126

127127
Set<String> chosenNodes = new HashSet<>();
@@ -138,7 +138,7 @@ public void testLeastRecentlyUsedNodesPickedFirst() throws Throwable {
138138
stopDrivers(drivers);
139139

140140
for (int i=0; i < 4; i++) {
141-
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
141+
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.htmlUnit(), hub));
142142
}
143143

144144
for (RemoteProxy p : ps) {
@@ -165,7 +165,7 @@ public void testLeastRecentlyUsedNodesPickedFirst() throws Throwable {
165165
stopDrivers(drivers);
166166

167167
for (int i=0; i < 4; i++) {
168-
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
168+
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.htmlUnit(), hub));
169169
}
170170

171171
for (RemoteProxy p : ps) {

java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testRegisterNodeToHub() throws Exception {
5454

5555
Integer nodePort = PortProber.findFreePort();
5656

57-
String[] nodeArgs = {"-role", "node", "-hub", "http://localhost:" + hubPort, "-browser", "browserName=chrome,maxInstances=1", "-port", nodePort.toString()};
57+
String[] nodeArgs = {"-role", "node", "-hub", "http://localhost:" + hubPort, "-browser", "browserName=htmlunit,maxInstances=1", "-port", nodePort.toString()};
5858
GridLauncherV3.main(nodeArgs);
5959
urlChecker.waitUntilAvailable(100, TimeUnit.SECONDS, new URL(String.format("http://localhost:%d/wd/hub/status", nodePort)));
6060

@@ -65,19 +65,19 @@ public Boolean apply(URL u) {
6565
try (InputStream is = u.openConnection().getInputStream();
6666
InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
6767
BufferedReader reader = new BufferedReader(isr)) {
68-
return reader.lines().anyMatch(l -> l.contains("chrome"));
68+
return reader.lines().anyMatch(l -> l.contains("htmlunit"));
6969
} catch (IOException ioe) {
7070
return false;
7171
}
7272
}
7373
});
7474

7575
WebDriver driver = new RemoteWebDriver(new URL(String.format("http://localhost:%d/wd/hub", hubPort)),
76-
DesiredCapabilities.chrome());
76+
DesiredCapabilities.htmlUnit());
7777

7878
try {
7979
driver.get(String.format("http://localhost:%d/grid/console", hubPort));
80-
Assert.assertEquals("Should only have one chrome registered to the hub", 1, driver.findElements(By.cssSelector("img[src$='chrome.png']")).size());
80+
Assert.assertEquals("Should only have one htmlunit registered to the hub", 1, driver.findElements(By.cssSelector("img[src$='htmlunit.png']")).size());
8181
} finally {
8282
try {
8383
driver.quit();

java/server/test/org/openqa/grid/e2e/node/SmokeTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public void prepare() throws Exception {
4949
GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE);
5050
remote.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 1);
5151

52-
DesiredCapabilities chromeOnSeleniumCapability = DesiredCapabilities.chrome();
53-
chromeOnSeleniumCapability.setCapability(RegistrationRequest.SELENIUM_PROTOCOL,SeleniumProtocol.WebDriver);
52+
DesiredCapabilities capabilities = DesiredCapabilities.htmlUnit();
53+
capabilities.setCapability(RegistrationRequest.SELENIUM_PROTOCOL,SeleniumProtocol.WebDriver);
5454

55-
remote.addBrowser(chromeOnSeleniumCapability, 1);
55+
remote.addBrowser(capabilities, 1);
5656

5757
remote.setRemoteServer(new SeleniumServer(remote.getConfiguration()));
5858
remote.startRemoteServer();
@@ -63,10 +63,10 @@ public void prepare() throws Exception {
6363
}
6464

6565
@Test
66-
public void chromeOnWebDriver() throws MalformedURLException {
66+
public void browserOnWebDriver() throws MalformedURLException {
6767
WebDriver driver = null;
6868
try {
69-
DesiredCapabilities caps = DesiredCapabilities.chrome();
69+
DesiredCapabilities caps = DesiredCapabilities.htmlUnit();
7070
driver = new RemoteWebDriver(hub.getWebDriverHubRequestURL(), caps);
7171
driver.get(hub.getConsoleURL().toString());
7272
assertEquals(driver.getTitle(), "Grid Console");

java/server/test/org/openqa/grid/e2e/utils/GridTestHelper.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,14 @@ public static DesiredCapabilities getSelenium1FirefoxCapability() {
5757
return firefoxOnSeleniumCapability;
5858
}
5959

60-
public static DesiredCapabilities getFirefoxCapability() {
61-
return DesiredCapabilities.firefox();
62-
}
63-
6460
public static DesiredCapabilities getDefaultBrowserCapability() {
6561
String browser = System.getProperty("webdriver.gridtest.browser");
6662
if (browser != null) {
6763
DesiredCapabilities caps = new DesiredCapabilities();
6864
caps.setBrowserName(browser);
6965
return caps;
7066
}
71-
return DesiredCapabilities.chrome();
67+
return DesiredCapabilities.htmlUnit();
7268
}
7369

7470
public static Hub getHub() throws Exception {

0 commit comments

Comments
 (0)