Class ParallelTest
- java.lang.Object
-
- com.vaadin.testbench.TestBenchTestCase
-
- com.vaadin.testbench.parallel.ParallelTest
-
- All Implemented Interfaces:
HasDriver,HasElementQuery,HasSearchContext,HasTestBenchCommandExecutor
public class ParallelTest extends TestBenchTestCase
Unit tests should extendParallelTestif they are to be run in several browser configurations. For each browser configuration, aWebDriveris properly created with the desired configuration.You can configure your tests to be run in Sauce Labs. See details at https://wiki.saucelabs.com and https://github.com/vaadin/testbench-demo.
-
-
Field Summary
Fields Modifier and Type Field Description ScreenshotOnFailureRulescreenshotOnFailure-
Fields inherited from class com.vaadin.testbench.TestBenchTestCase
driver, maxAttempts, testbenchVersion
-
-
Constructor Summary
Constructors Constructor Description ParallelTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<org.openqa.selenium.remote.DesiredCapabilities>getDefaultCapabilities()protected org.openqa.selenium.remote.DesiredCapabilitiesgetDesiredCapabilities()Gets theDesiredCapabilities(usually browser name and version)protected StringgetHubHostname()Returns the hostname of the hub where test is to be run on.protected StringgetHubURL()Returns the complete URL of the hub where the tests will be run on.protected BrowsergetRunLocallyBrowser()protected StringgetRunLocallyBrowserVersion()protected RunOnHubgetRunOnHub(Class<?> klass)voidsetDesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities desiredCapabilities)Sets the requestedDesiredCapabilities(usually browser name and version)voidsetup()Sets the driver for this test instance.-
Methods inherited from class com.vaadin.testbench.TestBenchTestCase
concatUrl, executeScript, findElement, findElements, getCommandExecutor, getContext, getDriver, setDriver, testBench, waitUntil, waitUntil, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.testbench.HasElementQuery
$, $
-
-
-
-
Field Detail
-
screenshotOnFailure
public ScreenshotOnFailureRule screenshotOnFailure
-
-
Method Detail
-
getHubURL
protected String getHubURL()
Returns the complete URL of the hub where the tests will be run on. Used by
setup(), for the creation of theWebDriver.This method uses
getHubHostname()to build the complete address of the Hub. Override in order to define a different hub address.
You can provide sauce.user and sauce.sauceAccessKey system properties or SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables to run the tests in Sauce Labs. If both system property and environment variable is defined, system property is prioritised.
- Returns:
- the complete URL of the hub where the tests will be run on. Used
by
setup(), for the creation of theWebDriver.
-
getHubHostname
protected String getHubHostname()
Returns the hostname of the hub where test is to be run on. If unit test is annotated by
RunLocally, this method returns localhost. Otherwise, it will return the host defined by thecom.vaadin.testbench.Parameters.hubHostnamesystem parameter or the host defined using aRunOnHubannotation.This method is used by
getHubURL()to get the full URL of the hub to run tests on.- Returns:
- the hostname of the hub where test is to be run on.
-
setup
public void setup() throws ExceptionSets the driver for this test instance. Uses
SetupDriver.setupRemoteDriver(String)orSetupDriver.setupLocalDriver(Browser)according to the annotations found in current test case.RunOnHubannotation can be used on the test case class to define a test hub's hostname for the driver to connect to it.
RunLocallyannotation can be used on the test case class to force the driver to connect to localhost (RunLocallyannotation overridesRunOnHubannotation).- Throws:
Exception- if unable to instantiateWebDriver
-
getRunOnHub
protected RunOnHub getRunOnHub(Class<?> klass)
- Returns:
- Value of the
RunOnHubannotation of current Class, or null if annotation is not present.
-
getRunLocallyBrowser
protected Browser getRunLocallyBrowser()
- Returns:
- Browser value of the
RunLocallyannotation of current Class, or null if annotation is not present.
-
getRunLocallyBrowserVersion
protected String getRunLocallyBrowserVersion()
- Returns:
- Version value of the
RunLocallyannotation of current Class, or empty empty String if annotation is not present.
-
getDefaultCapabilities
public static List<org.openqa.selenium.remote.DesiredCapabilities> getDefaultCapabilities()
- Returns:
- default capabilities, used if no
BrowserConfigurationmethod was found
-
setDesiredCapabilities
public void setDesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities desiredCapabilities)
Sets the requestedDesiredCapabilities(usually browser name and version)- Parameters:
desiredCapabilities-
-
getDesiredCapabilities
protected org.openqa.selenium.remote.DesiredCapabilities getDesiredCapabilities()
Gets theDesiredCapabilities(usually browser name and version)- Returns:
-
-