Skip to content

Commit

Permalink
[grid] Refactoring tests to use driver specified by "webdriver.gridte…
Browse files Browse the repository at this point in the history
…st.browser" property
  • Loading branch information
barancev committed Apr 8, 2019
1 parent f512540 commit c8a6816
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public class GridDistributionTest {
private List<WebDriver> drivers = new ArrayList<>();

@Before
public void prepare() throws Exception {
public void prepare() {

hub = GridTestHelper.getHub();

for (int i =0; i < 8; i++) {
SelfRegisteringRemote remote =
GridTestHelper.getRemoteWithoutCapabilities(hub, GridRole.NODE);

remote.addBrowser(DesiredCapabilities.htmlUnit(), 3);
remote.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 3);
remote.setRemoteServer(new SeleniumServer(remote.getConfiguration()));
remote.startRemoteServer();
remote.sendRegistrationRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void runTest(int nodesCount, int howMany,
Hub hub = null;
List<RemoteWebDriver> drivers = new ArrayList<>();
try {
hub = GridTestHelper.prepareTestGrid(DesiredCapabilities.htmlUnit(), nodesCount);
hub = GridTestHelper.prepareTestGrid(nodesCount);
drivers = createSession(howMany, hub);
Map<String, Object> sessions = getSessions(hub);
assertions.accept(sessions);
Expand All @@ -114,7 +114,7 @@ private List<RemoteWebDriver> createSession(int howMany, Hub hub) {
return new ArrayList<>();
}
for (int i = 0; i < howMany; i++) {
drivers.add(new RemoteWebDriver(url, DesiredCapabilities.htmlUnit()));
drivers.add(new RemoteWebDriver(url, GridTestHelper.getDefaultBrowserCapability()));
}
return drivers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
import org.openqa.grid.shared.Stoppable;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.net.UrlChecker;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.http.HttpClient;
Expand Down
6 changes: 2 additions & 4 deletions java/server/test/org/openqa/grid/e2e/node/SmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import org.junit.Test;
import org.openqa.grid.e2e.utils.GridTestHelper;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

Expand All @@ -36,14 +34,14 @@ public class SmokeTest {

@Before
public void prepare() {
hub = GridTestHelper.prepareTestGrid(DesiredCapabilities.htmlUnit(), 1);
hub = GridTestHelper.prepareTestGrid(1);
}

@Test
public void browserOnWebDriver() {
WebDriver driver = null;
try {
DesiredCapabilities caps = DesiredCapabilities.htmlUnit();
DesiredCapabilities caps = GridTestHelper.getDefaultBrowserCapability();
driver = new RemoteWebDriver(hub.getWebDriverHubRequestURL(), caps);
driver.get(hub.getConsoleURL().toString());
assertEquals(driver.getTitle(), "Grid Console");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public static Hub getHub(GridHubConfiguration config) {
return hub;
}

public static Hub prepareTestGrid(int nodeCount) {
return prepareTestGrid(getDefaultBrowserCapability(), nodeCount);
}

public static Hub prepareTestGrid(Capabilities caps, int nodeCount) {
Hub hub = GridTestHelper.getHub();

Expand Down

0 comments on commit c8a6816

Please sign in to comment.