diff options
author | Artur Signell <artur@vaadin.com> | 2014-03-25 13:45:37 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-07 08:24:14 +0000 |
commit | 18143dddcec64f6ba2a610f51abdb25272a8d129 (patch) | |
tree | 30951436431058244ae7c5ed8684eb4a8948390b /uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | |
parent | 8a0e51fac162d50c7f3e7ad337c98ba53e2abe63 (diff) | |
download | vaadin-framework-18143dddcec64f6ba2a610f51abdb25272a8d129.tar.gz vaadin-framework-18143dddcec64f6ba2a610f51abdb25272a8d129.zip |
Retry browser startup multiple times for more stability
Change-Id: Ia46ee4b30809a978e95b67a4f5dfe74bd0125eb3
Diffstat (limited to 'uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java')
-rw-r--r-- | uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 6f934011f5..ecba419472 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -89,6 +89,8 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ private static final int BROWSER_TIMEOUT_IN_MS = 30 * 1000; + private static final int BROWSER_INIT_ATTEMPTS = 5; + private DesiredCapabilities desiredCapabilities; private boolean debug = false; @@ -138,9 +140,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { if (localWebDriverIsUsed()) { setupLocalDriver(capabilities); } else { - WebDriver dr = TestBench.createDriver(new RemoteWebDriver( - new URL(getHubURL()), capabilities)); - setDriver(dr); + setupRemoteDriver(capabilities); } } @@ -223,6 +223,32 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { DesiredCapabilities desiredCapabilities); /** + * Creates a {@link WebDriver} instance used for running the test remotely. + * + * @since + * @param capabilities + * the type of browser needed + * @throws Exception + */ + private void setupRemoteDriver(DesiredCapabilities capabilities) + throws Exception { + for (int i = 1; i <= BROWSER_INIT_ATTEMPTS; i++) { + try { + WebDriver dr = TestBench.createDriver(new RemoteWebDriver( + new URL(getHubURL()), capabilities)); + setDriver(dr); + } catch (Exception e) { + System.err.println("Browser startup for " + capabilities + + " failed on attempt " + i + ": " + e.getMessage()); + if (i == BROWSER_INIT_ATTEMPTS) { + throw e; + } + } + } + + } + + /** * Opens the given test (defined by {@link #getTestUrl()}, optionally with * debug window and/or push (depending on {@link #isDebug()} and * {@link #isPush()}. |