Testing

UI Testing with linkki Extension for Vaadin TestBench

UI Testing of linkki components is based on the Vaadin TestBench that uses Selenium.

A Vaadin TestBench license is needed to run linkki UI tests!

linkki-vaadin-flow-TestBench-extension is an extension to the Vaadin TestBench that brings page objects for linkki components like LinkkiSectionElement and LinkkiTextElement.

Maven Dependency

<dependency>
    <groupId>org.linkki-framework</groupId>
    <artifactId>linkki-vaadin-flow-TestBench-extension</artifactId>
</dependency>

Example Usage

This example tests the text of a LinkkiText component on a website at /app/home.

public class LinkkiUiTest extends AbstractLinkkiUiTest {

    public static final String DEFAULT_CONTEXT_PATH = "app";

    @RegisterExtension
    protected static WebDriverExtension driverExtension = new WebDriverExtension(DEFAULT_CONTEXT_PATH);

    @BeforeEach
    public void setUp() {
        setCurrentExtension(driverExtension);
    }

    @Test
    void testLinkkiText() {
        goToView("home");

        LinkkiTextElement linkkiText = $(LinkkiTextElement.class).id("linkki-text-id");

        assertThat(linkkiText.getText()).isEqualTo("linkki text element content");
    }

    private void goToView(String viewName) {
        getDriver().navigate().to(DriverProperties.getTestUrl(DEFAULT_CONTEXT_PATH, viewName));
    }

}

DriverProperties

DriverProperties can be used to build the URI for the application to be tested. It uses the following system properties, where <systemName> is an optional suffix that scopes the property to a named deployment:

Property

Description

Default

test.protocol[.<systemName>]

Protocol

http

test.hostname[.<systemName>]

Hostname

localhost

test.port[.<systemName>]

Port

8080

test.path[.<systemName>]

Path

-

test.headless

Run browser in headless mode

false

Testing Multiple Deployments

To test multiple deployments in the same test suite, create one WebDriverExtension per system:

@RegisterExtension
protected static WebDriverExtension systemADriver = new WebDriverExtension("systemA", SYSTEM_A_CONTEXT_PATH);

@RegisterExtension
protected static WebDriverExtension systemBDriver = new WebDriverExtension("systemB", SYSTEM_B_CONTEXT_PATH);

Each extension resolves its base URL from the system-scoped properties test.hostname.<systemName>, test.port.<systemName>, and test.protocol.<systemName>.

AbstractLinkkiUiTest provides a setCurrentExtension method to control, which deployment is targeted next.