Getting Started with Browserless Testing
This page lists the test dependencies for each supported application framework, and a minimal test class that the snippets on the following pages build on.
Dependencies
With the Vaadin Bill-of-Materials (BOM) imported in a Maven project, add the dependencies for your framework with a test scope.
The BOM defines the versions of the Vaadin artifacts.
Source code
XML
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>browserless-test-junit6</artifactId>
<scope>test</scope>
</dependency>XML
XML
XML
XML
XML
XML
XML
A Java EE/CDI project also needs Vaadin CDI and the provided Jakarta EE APIs, which the application already has.
Minimal Test Class
A test class extends the base class of its framework.
Before each test method, the Plain Java, Spring Boot, and Quarkus base classes create the Vaadin environment with one user and one window, and open the root view; after the test method, they clean the environment up.
The test calls the testing methods, such as navigate(), on itself.
Source code
Java
import org.junit.jupiter.api.Test;
import com.vaadin.browserless.BrowserlessTest;
class MyViewTest extends BrowserlessTest {
@Test
void myTest() {
MyView view = navigate(MyView.class);
// Find components and simulate user actions
}
}Java
Java
Java
Java
Java
Java
Java
These base classes scan the whole classpath for routes, unless the test class has a @ViewPackages annotation.
A Java EE/CDI test extends AbstractCdiViewTest, an application-owned subclass of BrowserlessTest that starts the Vaadin environment with Weld and CdiVaadinServlet, and registers the routes that the tests use instead of scanning for them.
See CDI Test Integration for that class.
Locators
The optional Locators interface provides additional convenience methods: typed locator entry points, such as findButton() and findTextField().
To use them in a test that extends a base class, implement the interface in the test class, as described in Opting in for BrowserlessTest.
Using the Snippets on the Following Pages
Most snippets on the following pages call the testing methods on window, a window of an application context.
In a test that extends a base class, call the same methods on the test class itself: window.navigate() becomes navigate(), and window.findButton() becomes findButton() when the test class implements Locators.
Snippets that create users and windows from app need an application context, which a test sets up when it needs several users or windows, or more control over the Vaadin environment; see Setting Up an Application Context.
4D59DA39-8F41-49F4-B25D-09074A06FA3A