]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make it possible to override web driver in tests (#12572)
authorArtur Signell <artur@vaadin.com>
Mon, 23 Sep 2013 12:46:20 +0000 (15:46 +0300)
committerArtur Signell <artur@vaadin.com>
Mon, 23 Sep 2013 12:48:48 +0000 (15:48 +0300)
Change-Id: If696c8a57fc370d2851592d745ab8a2698631ed5

uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java

index f27fff587388f3fb481313632cd0cfafd81605f5..966be1a692f6e57df7fe10ccbd52daeec9fff39d 100644 (file)
@@ -72,13 +72,36 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
      * Connect to the hub using a remote web driver, set the canvas size and
      * opens the initial URL as specified by {@link #getTestUrl()}
      * 
-     * @throws MalformedURLException
+     * @throws Exception
      */
     @Before
-    public void setup() throws MalformedURLException {
+    public void setup() throws Exception {
+        setupDriver();
+
+        String testUrl = getTestUrl();
+        if (testUrl != null) {
+            driver.get(testUrl);
+        }
+    }
+
+    /**
+     * Creates and configure the web driver to be used for the test. By default
+     * creates a remote web driver which connects to {@link #getHubURL()} and
+     * selects a browser based on {@link #getDesiredCapabilities()}.
+     * 
+     * This method MUST call {@link #setDriver(WebDriver)} with the newly
+     * generated driver.
+     * 
+     * @throws Exception
+     *             If something goes wrong
+     */
+    protected void setupDriver() throws Exception {
         DesiredCapabilities capabilities = getDesiredCapabilities();
-        driver = TestBench.createDriver(new RemoteWebDriver(
-                new URL(getHubURL()), capabilities));
+
+        WebDriver dr = TestBench.createDriver(new RemoteWebDriver(new URL(
+                getHubURL()), capabilities));
+        setDriver(dr);
+
         int w = SCREENSHOT_WIDTH;
         int h = SCREENSHOT_HEIGHT;
 
@@ -93,10 +116,6 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
             // Opera does not support this...
         }
 
-        String testUrl = getTestUrl();
-        if (testUrl != null) {
-            driver.get(testUrl);
-        }
     }
 
     /**