From ae44989b05eed41de6b8ee54dd886ad01e89e78c Mon Sep 17 00:00:00 2001 From: Henri Sara Date: Thu, 28 Apr 2016 08:54:26 +0300 Subject: Add a way to override browser factory Use the parameter browser.factory to select a class implementing TestBenchBrowserFactory. Change-Id: Ibc1f11ad83f8ac1ed85766892cfa0463af9bf440 --- .../com/vaadin/tests/tb3/VaadinBrowserFactory.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/VaadinBrowserFactory.java b/uitest/src/test/java/com/vaadin/tests/tb3/VaadinBrowserFactory.java index 294fe440d0..19ef7a5db1 100644 --- a/uitest/src/test/java/com/vaadin/tests/tb3/VaadinBrowserFactory.java +++ b/uitest/src/test/java/com/vaadin/tests/tb3/VaadinBrowserFactory.java @@ -15,17 +15,44 @@ */ package com.vaadin.tests.tb3; +import java.util.logging.Logger; + import org.openqa.selenium.Platform; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.parallel.Browser; import com.vaadin.testbench.parallel.DefaultBrowserFactory; +import com.vaadin.testbench.parallel.TestBenchBrowserFactory; public class VaadinBrowserFactory extends DefaultBrowserFactory { + TestBenchBrowserFactory delegate = null; + @Override public DesiredCapabilities create(Browser browser) { + String browserFactoryClass = System.getProperty("browser.factory"); + if (browserFactoryClass != null + && !browserFactoryClass.trim().isEmpty()) { + if (delegate == null) { + getLogger() + .info("Using browser factory " + browserFactoryClass); + try { + delegate = (TestBenchBrowserFactory) getClass() + .getClassLoader().loadClass(browserFactoryClass) + .newInstance(); + } catch (Exception e) { + getLogger().warning("Failed to instantiate browser factory " + browserFactoryClass); + throw new RuntimeException(e); + } + } + return delegate.create(browser); + } + + return doCreate(browser); + } + + public DesiredCapabilities doCreate(Browser browser) { switch (browser) { case IE8: return createIE(browser, "8"); @@ -59,4 +86,8 @@ public class VaadinBrowserFactory extends DefaultBrowserFactory { capabilities.setVersion(version); return capabilities; } + + private static final Logger getLogger() { + return Logger.getLogger(VaadinBrowserFactory.class.getName()); + } } -- cgit v1.2.3