Extend AbstractBasePlaywrightIT to set up Playwright for your tests:
package com.example.tests;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;import org.springframework.boot.test.web.server.LocalServerPort;import org.vaadin.addons.dramafinder.AbstractBasePlaywrightIT;@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)public abstract class BaseIT extends AbstractBasePlaywrightIT { @LocalServerPort private int port; @Override public String getUrl() { return String.format("http://localhost:%d/", port); }}
The AbstractBasePlaywrightIT class handles browser lifecycle, page setup, and Vaadin synchronization automatically.
2
Write your first test
Create a test class for a simple form:
package com.example.tests;import org.junit.jupiter.api.Test;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;import org.vaadin.addons.dramafinder.element.TextFieldElement;@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)public class SimpleExampleIT extends BaseIT { @Test public void testTooltip() { // Get a text field by its accessible label TextFieldElement textfield = TextFieldElement.getByLabel(page, "Textfield"); // Assert that it's visible textfield.assertVisible(); // Assert that the textfield has a tooltip textfield.assertTooltipHasText("Tooltip for textfield"); }}
Drama Finder provides comprehensive support for Vaadin text fields with intuitive methods:
// Find by labelTextFieldElement textfield = TextFieldElement.getByLabel(page, "Username");// Assert visibilitytextfield.assertVisible();// Set and verify valuetextfield.setValue("john.doe");textfield.assertValue("john.doe");// Clear the fieldtextfield.clear();textfield.assertValue("");
Elements provide flexible factory methods for different lookup strategies:
// Find by accessible label on the pageTextFieldElement field = TextFieldElement.getByLabel(page, "Email");ButtonElement button = ButtonElement.getByText(page, "Submit");