diff --git a/java/client/test/org/openqa/selenium/javascript/JsTestSuiteBuilder.java b/java/client/test/org/openqa/selenium/javascript/JsTestSuiteBuilder.java index 8eef2e255422c..0f77d0bec3005 100644 --- a/java/client/test/org/openqa/selenium/javascript/JsTestSuiteBuilder.java +++ b/java/client/test/org/openqa/selenium/javascript/JsTestSuiteBuilder.java @@ -53,16 +53,16 @@ class JsTestSuiteBuilder { private static final boolean NO_REFRESH_DRIVER = false; private Function testFactory = null; -// private Class driverClazz = null; + private Supplier driverSupplier = new WebDriverBuilder(); /** - * @param driverClazz The type of {@link WebDriver} that should be used to - * run the tests. + * @param driverSupplier The supplier to use for acquiring {@link WebDriver} + * instances when running the tests. * @return A self reference. */ - public JsTestSuiteBuilder withDriverClazz( - Class driverClazz) { -// this.driverClazz = checkNotNull(driverClazz); + public JsTestSuiteBuilder withDriverSupplier( + Supplier driverSupplier) { + this.driverSupplier = checkNotNull(driverSupplier); return this; } @@ -82,14 +82,11 @@ public JsTestSuiteBuilder withTestFactory( */ public Test build() { checkNotNull(testFactory, "No path to test function specified"); -// checkNotNull(driverClazz, "No driver class specified"); File testDirectory = getTestDirectory(); ImmutableSet excludedFiles = getExcludedFiles(testDirectory); String basePath = getTestUrlPath(); - Supplier driverSupplier = new WebDriverBuilder(); - TestSuite suite = new TestSuite(); List testFiles = findTestFiles(testDirectory, new TestFilenameFilter(excludedFiles)); diff --git a/java/client/test/org/openqa/selenium/javascript/WebDriverJsTestSuite.java b/java/client/test/org/openqa/selenium/javascript/WebDriverJsTestSuite.java index d711e578b464d..5b14c1ab3b563 100644 --- a/java/client/test/org/openqa/selenium/javascript/WebDriverJsTestSuite.java +++ b/java/client/test/org/openqa/selenium/javascript/WebDriverJsTestSuite.java @@ -17,16 +17,6 @@ package org.openqa.selenium.javascript; -import com.google.common.base.Function; - -import junit.extensions.TestSetup; -import junit.framework.Test; -import junit.framework.TestCase; - -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.json.JSONException; -import org.json.JSONObject; import org.openqa.selenium.DriverTestDecorator; import org.openqa.selenium.NeedsDriver; import org.openqa.selenium.Platform; @@ -36,6 +26,17 @@ import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.base.Throwables; +import junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestCase; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHolder; +import org.json.JSONException; +import org.json.JSONObject; + import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; @@ -48,7 +49,7 @@ public static Test suite() { final AppServer appServer = createAppServer(testEventServlet); Test test = new JsTestSuiteBuilder() - .withDriverClazz(RemoteWebDriverForTest.class) + .withDriverSupplier(createDriverSupplier()) .withTestFactory(new Function() { public Test apply(String testPath) { return new WebDriverJsTestCase(testPath, appServer, @@ -73,6 +74,18 @@ private static AppServer createAppServer(TestEventServlet resultsServlet) { appServer.addHandler(context); return appServer; } + + private static Supplier createDriverSupplier() { + return new Supplier() { + public WebDriver get() { + try { + return new RemoteWebDriverForTest(); + } catch (MalformedURLException e) { + throw Throwables.propagate(e); + } + } + }; + } private static DesiredCapabilities getCapabilities() { DesiredCapabilities capabilities = new DesiredCapabilities();