> Markdown version of [Getting Started](https://vaadin.com/docs/latest/flow/testing/browserless/getting-started). Section index: [llms.txt](https://vaadin.com/docs/latest/flow/llms.txt)

# 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.

## <a id="dependencies"></a>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.

**Plain Java**

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>browserless-test-junit6</artifactId>
    <scope>test</scope>
</dependency>
```

**Spring Boot**

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>browserless-test-spring</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

<!-- Optional: Spring Security test annotations, such as @WithMockUser -->
<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-test</artifactId>
    <scope>test</scope>
</dependency>
```

**Quarkus**

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>browserless-test-junit6</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>browserless-test-quarkus</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-junit</artifactId>
    <scope>test</scope>
</dependency>

<!-- Optional: Quarkus Security test annotation @TestSecurity -->
<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-test-security</artifactId>
    <scope>test</scope>
</dependency>
```

**Java EE/CDI**

```xml
<dependency>
    <groupId>com.vaadin</groupId>
    <artifactId>browserless-test-junit6</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.weld</groupId>
    <artifactId>weld-junit5</artifactId>
    <version>5.0.3.Final</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <scope>test</scope>
</dependency>

<!-- In <dependencyManagement>, unless your parent POM already manages JUnit -->
<dependency>
    <groupId>org.junit</groupId>
    <artifactId>junit-bom</artifactId>
    <version>6.0.3</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
```

A Java EE/CDI project also needs [Vaadin CDI](https://vaadin.com/docs/latest/flow/integrations/cdi.md#add-dependencies) and the provided Jakarta EE APIs, which the application already has.

The optional security dependencies provide the test annotations that set the user of the [Spring](https://vaadin.com/docs/latest/flow/testing/browserless/spring-security.md) and [Quarkus](https://vaadin.com/docs/latest/flow/testing/browserless/quarkus.md#security-integration) base classes. A secured application context needs only the application’s own Spring Security or Quarkus Security.

## <a id="minimal-test-class"></a>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.

**Plain Java**

```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
    }
}
```

**Spring Boot**

```java
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import com.vaadin.browserless.SpringBrowserlessTest;

@SpringBootTest
class MyViewTest extends SpringBrowserlessTest {

    @Test
    void myTest() {
        MyView view = navigate(MyView.class);
        // Find components and simulate user actions
    }
}
```

**Quarkus**

```java
import org.junit.jupiter.api.Test;
import com.vaadin.browserless.quarkus.QuarkusBrowserlessTest;
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class MyViewTest extends QuarkusBrowserlessTest {

    @Test
    void myTest() {
        MyView view = navigate(MyView.class);
        // Find components and simulate user actions
    }
}
```

**Java EE/CDI**

```java
import org.junit.jupiter.api.Test;

class MyViewTest extends AbstractCdiViewTest {

    @Test
    void myTest() {
        MyView view = navigate(MyView.class);
        // Find components and simulate user actions
    }
}
```

These base classes scan the whole classpath for routes, unless the test class has a [`@ViewPackages`](https://vaadin.com/docs/latest/flow/testing/browserless/test-environment.md#route-scanning) 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](https://vaadin.com/docs/latest/flow/testing/browserless/cdi.md#test-base-class) for that class.

### <a id="locators"></a>Locators

The optional `Locators` interface provides additional convenience methods: typed [locator](https://vaadin.com/docs/latest/flow/testing/browserless/locators.md) 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`](https://vaadin.com/docs/latest/flow/testing/browserless/locators.md#opting-in).

## <a id="using-the-snippets-on-the-following-pages"></a>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](https://vaadin.com/docs/latest/flow/testing/browserless/multi-user.md). 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](https://vaadin.com/docs/latest/flow/testing/browserless/multi-user.md#setting-up-an-application-context).

`4D59DA39-8F41-49F4-B25D-09074A06FA3A`
