Installation of Vaadin TestBench covers the following tasks:

  • Download and unpack the Vaadin TestBench installation package

  • Install Vaadin TestBench Recorder

  • Install Vaadin TestBench Library

Which modules you need to install depends on whether you are developing tests or running existing tests. Two basic installation types are covered in these instructions:

  • Test development installation on a workstation

  • Distributed grid installation

In a typical test development setup, you install Vaadin TestBench on a workstation. You can use the TestBench Recorder to record test cases and export them as JUnit test case stubs. This is especially recommended if you are new to Vaadin TestBench and do not want to code from scratch. You can install the Recorder in Firefox as described in Section 20.2.6, “Installing the Recorder”.

You may find it convenient to develop and execute tests under an IDE such as Eclipse. The special support for running JUnit test cases in Eclipse is described in Section 20.5.3, “Running JUnit Tests in Eclipse”.

In such a test development setup, you do not need a grid hub or nodes. However, if you develop tests for a grid, you can run the tests, the grid hub, and one node all in your development workstation. A distributed setup is described in the following section.

The installation package contains the following:

documentation

The documentation folder contains the TestBench library API documentation, a PDF excerpt of this chapter of Book of Vaadin, and the license.

example

The example folder provides TestBench examples. An example Maven configuration POM is given, as well as the JUnit test Java source files. For a description of the contents, see Section 20.2.5, “Example Contents”.

maven

The Maven folder contains version of the Vaadin TestBench libraries that you can install in your local Maven repository. Please follow the instructions in Section 20.5.5, “Executing Tests with Maven”.

vaadin-testbench-recorder

This folder constains the Vaadin TestBench Recorder, which you can install in Firefox. Please follow the instructions in Section 20.2.6, “Installing the Recorder”.

vaadin-testbench-standalone-3.1.0.jar

This is the Vaadin TestBench library. It is a standalone library that includes the Selenium WebDriver and many other required libraries.

vaadin-testbench-standalone-3.1.0-javadoc.jar

This is the JavaDoc API documentation for the TestBench library. If you use Eclipse, you can associate the JAR with the TestBench JAR in the project preferences, in the build path library settings.

The example/maven folder provides a number of examples for using Vaadin TestBench. The source code for the application to be tested, a desktop calculator application, is given in the src/main/java subfolder.

The tests examples given under the src/test/java subfolder, in the com/vaadin/testbenchexample package subfolder, are as follows:

SimpleCalculatorITCase.java

Demonstrates the basic use of WebDriver. Interacts with the buttons in the user interface by clicking them and checks the resulting value. Uses By.id() to access the elements.

LoopingCalculatorITCase.java

Otherwise as the simple example, but shows how to use looping to produce programmatic repetition to create a complex use case.

ScreenshotITCase.java

Shows how to compare screenshots, as described in Section 20.6, “Taking and Comparing Screenshots”. Some of the test cases include random input, so they require masked screenshot comparison to mask the random areas out.

The included reference images were taken with Firefox on Mac OS X, so if you use another platform, they will fail. You will need to copy the error images to the reference screenshot folder and mask out the areas with the alpha channel as described in Section 20.6.3, “Taking Screenshots for Comparison”.

SelectorExamplesITCase.java

This example shows how to use different selectors:

  • By.id() - selecting by identifier
  • By.xpath() - selecting by an XPath expression
VerifyExecutionTimeITCase.java

Shows how to time the execution of a test case and how to report it.

AdvancedCommandsITCase.java

Demonstrates how to test tooltips (Section 20.5.10, “Testing Tooltips”) and context menus. Uses debug IDs, XPath expressions, as well as CSS selectors to find the elements to check.

For information about running the examples with Maven, see Section 20.5.5, “Executing Tests with Maven”.

Whether developing tests with the WebDriver in the workstation or running tests in a grid, using some browsers requires that a browser driver is installed.

  1. Download the latest browser driver

  2. Add the driver executable to PATH or define it as a system property in the application using WebDriver locally, or in distributed use give it as a command-line parameter to the grid node service, as described in Section 20.7.4, “Starting a Grid Node”.