Package com.vaadin.flow.testutil
Class AbstractTestBenchTest
java.lang.Object
com.vaadin.testbench.TestBenchTestCase
com.vaadin.testbench.parallel.ParallelTest
com.vaadin.flow.testutil.TestBenchHelpers
com.vaadin.flow.testutil.AbstractTestBenchTest
- All Implemented Interfaces:
com.vaadin.testbench.HasDriver,com.vaadin.testbench.HasElementQuery,com.vaadin.testbench.HasSearchContext,com.vaadin.testbench.HasTestBenchCommandExecutor
- Direct Known Subclasses:
ViewOrUITest
Abstract base class for flow TestBench tests.
- Since:
- 1.0
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final intServer port resolved by system property "serverPort" or the default "8888".static final StringSystem property key for the test server port.org.junit.rules.TestNamestatic final booleanstatic final Stringstatic final booleanstatic final StringFields inherited from class com.vaadin.testbench.parallel.ParallelTest
screenshotOnFailureFields inherited from class com.vaadin.testbench.TestBenchTestCase
driver, maxAttempts -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassertImageEquals(Path pathToExpectedImage, String imageUrl) protected voidassertRuleOnce(String style) voidChecks that server is available before running the actual test.protected List<org.openqa.selenium.remote.DesiredCapabilities> getBrowserCapabilities(com.vaadin.testbench.parallel.Browser... browsers) Gets browser capabilities for the providedbrowsers.List<org.openqa.selenium.remote.DesiredCapabilities> Produces a collection of browsers to run the test on.protected StringReturns host address that can be targeted from the outside, like from a test hub.protected StringUsed to determine what URL to initially open for the test.protected intUsed to determine what port the test is running on.protected List<org.openqa.selenium.remote.DesiredCapabilities> Gets the browsers capabilities list to execute test on the tests Hub.protected Stringprotected Optional<LocalExecution> Gets local execution (LocalExecution) configuration for the test.protected StringReturns the URL to the root of the server, e.g.protected com.vaadin.testbench.parallel.Browserprotected Stringprotected abstract StringGets the absolute path to the test, starting with a "/".protected StringgetTestURL(String... parameters) Returns the URL to be used for the test.static StringgetTestURL(String rootUrl, String testPath, String... parameters) Returns the URL to be used for the test.protected final booleanReturns true when using clientSide routingprotected voidopen()protected voidprotected voidopenForEs6Url(String... parameters) protected voidprotected voidverifyScreenshot(String identifier) Compares the given reference screenshot to the current and fails the test if it doesn't match.protected voidWaits until clientSide route renders the view.protected voidwaitForFont(String fontSizeAndName) protected voidwaitForWebComponent(String tagName) protected voidMethods inherited from class com.vaadin.flow.testutil.TestBenchHelpers
assertEquals, blur, checkLogsForErrors, checkLogsForErrors, clickElementWithJs, clickElementWithJs, drag, dragAndDrop, dragElementOver, executeScript, getLogEntries, getScrollX, getScrollY, hasCssClass, isElementPresent, scrollBy, scrollIntoViewAndClick, scrollToElement, waitForDevServer, waitForElementNotPresent, waitForElementPresent, waitForElementVisible, waitUntilNot, waitUntilNotMethods inherited from class com.vaadin.testbench.parallel.ParallelTest
getDefaultCapabilities, getDesiredCapabilities, getHubURL, getRunOnHub, setDesiredCapabilities, setupMethods inherited from class com.vaadin.testbench.TestBenchTestCase
concatUrl, findElement, findElements, getCommandExecutor, getContext, getDriver, setDriver, testBench, waitUntil, waitUntil, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.testbench.HasElementQuery
$, $
-
Field Details
-
SERVER_PORT_PROPERTY_KEY
System property key for the test server port.- See Also:
-
SERVER_PORT
public static final int SERVER_PORTServer port resolved by system property "serverPort" or the default "8888". -
USE_HUB_PROPERTY
- See Also:
-
USE_HUB
public static final boolean USE_HUB -
USE_BROWSERSTACK_PROPERTY
- See Also:
-
USE_BROWSERSTACK
public static final boolean USE_BROWSERSTACK -
BROWSERSTACK_IDENTIFIER_PROPERTY
- See Also:
-
BROWSERSTACK_IDENTIFIER
-
testName
public org.junit.rules.TestName testName
-
-
Constructor Details
-
AbstractTestBenchTest
public AbstractTestBenchTest()
-
-
Method Details
-
checkIfServerAvailable
public void checkIfServerAvailable()Checks that server is available before running the actual test. -
open
protected void open() -
open
-
openForEs6Url
-
openUrl
-
isClientRouter
protected final boolean isClientRouter()Returns true when using clientSide routing- Returns:
- true when client-side route
-
waitForClientRouter
protected void waitForClientRouter()Waits until clientSide route renders the view. -
waitForWebComponentsBootstrap
protected void waitForWebComponentsBootstrap() -
waitForWebComponent
-
getTestURL
Returns the URL to be used for the test.- Parameters:
parameters- query string parameters to add to the url- Returns:
- the URL for the test
-
getTestPath
Gets the absolute path to the test, starting with a "/".- Returns:
- the path to the test, appended to
getRootURL()for the full test URL.
-
getRootURL
Returns the URL to the root of the server, e.g. "http://localhost:8888"- Returns:
- the URL to the root
-
verifyScreenshot
Compares the given reference screenshot to the current and fails the test if it doesn't match.- Parameters:
identifier- the identifier to use for the screenshot, becomes part of the screenshot name in themodule-folder/reference-screenshots/folder- Throws:
IOException- if there was a problem accessing the reference image
-
getBrowsersToTest
Produces a collection of browsers to run the test on. This method is executed by the test runner when determining how many test methods to invoke and with what parameters. For each returned value a test method is ran and before running that,ParallelTest.setDesiredCapabilities(DesiredCapabilities)is invoked with the value returned by this method.- Returns:
- The browsers to run the test on
-
getHubBrowsersToTest
Gets the browsers capabilities list to execute test on the tests Hub.This list will be used only for the tests Hub. Local test execution is managed by
LocalExecutionannotation.The method
getBrowsersToTest()delegates the logic to this method in casegetLocalExecution()return value is an empty optional (i.e. the tests Hub is used).- Returns:
- the browsers capabilities list to execute test on the tests Hub
-
getBrowserCapabilities
protected List<org.openqa.selenium.remote.DesiredCapabilities> getBrowserCapabilities(com.vaadin.testbench.parallel.Browser... browsers) Gets browser capabilities for the providedbrowsers.- Parameters:
browsers- a browsers list- Returns:
- the capabilities for the given
browsers
-
getDeploymentHostname
Used to determine what URL to initially open for the test.- Returns:
- the host name of development server
-
getCurrentHostAddress
Returns host address that can be targeted from the outside, like from a test hub.- Returns:
- host address
- Throws:
RuntimeException- if host name could not be determined orSocketExceptionwas caught during the determination.
-
getDeploymentPort
protected int getDeploymentPort()Used to determine what port the test is running on.- Returns:
- The port the test is running on, by default AbstractTestBenchTest.DEFAULT_SERVER_PORT
-
getHubHostname
- Overrides:
getHubHostnamein classcom.vaadin.testbench.parallel.ParallelTest
-
getRunLocallyBrowser
protected com.vaadin.testbench.parallel.Browser getRunLocallyBrowser()- Overrides:
getRunLocallyBrowserin classcom.vaadin.testbench.parallel.ParallelTest
-
getRunLocallyBrowserVersion
- Overrides:
getRunLocallyBrowserVersionin classcom.vaadin.testbench.parallel.ParallelTest
-
getLocalExecution
Gets local execution (LocalExecution) configuration for the test.If this method return an empty optional then test with be run on the test Hub
- Returns:
- an optional configuration, or an empty optional if configuration is disabled or not available
- See Also:
-
getTestURL
Returns the URL to be used for the test.- Parameters:
rootUrl- the root URL of the server (hostname + port)testPath- the path of the testparameters- query string parameters to add to the url- Returns:
- the URL for the test
-
assertImageEquals
- Throws:
IOException
-
waitForFont
-
assertRuleOnce
-