Skip to main content

DetailsElement

Playwright element wrapper for <vaadin-details> providing helpers to open/close and access the summary and content areas.

Component Tag

vaadin-details

Implements

  • HasStyleElement - CSS class and style management
  • HasThemeElement - Theme variant support
  • HasTooltipElement - Tooltip text

Constructor

locator
Locator
required
Playwright locator for the <vaadin-details> element

Static Factory Methods

getBySummaryText

Get a details component by its summary text.
DetailsElement.getBySummaryText(Page page, String summary)
page
Page
Playwright page
summary
String
Summary text to match

Methods

isOpen

Whether the details is opened.
boolean isOpen()

setOpen

Set the opened state by clicking the summary when necessary.
void setOpen(boolean open)
open
boolean
Desired open state

getSummaryLocator

Locator for the summary element.
Locator getSummaryLocator()

getSummaryText

Text content of the summary element.
String getSummaryText()

getContentLocator

Locator for the currently visible content container.
Locator getContentLocator()

Assertion Methods

assertEnabled

Assert that the component is enabled.
void assertEnabled()

assertDisabled

Assert that the component is disabled.
void assertDisabled()

assertOpened

Assert that the details is opened.
void assertOpened()

assertClosed

Assert that the details is closed.
void assertClosed()

assertContentVisible

Assert that the content is visible.
void assertContentVisible()

assertContentNotVisible

Assert that the content is not visible.
void assertContentNotVisible()

Usage Examples

Toggle Details Open/Close

DetailsElement details = DetailsElement.getBySummaryText(page, "Click to expand");
details.assertClosed();
details.setOpen(true);
details.assertOpened();
details.assertContentVisible();

Check Summary and Content

DetailsElement details = DetailsElement.getBySummaryText(page, "More info");
String summaryText = details.getSummaryText();
assertEquals("More info", summaryText);

if (details.isOpen()) {
    assertThat(details.getContentLocator()).containsText("Additional details");
}

Work with Disabled Details

DetailsElement details = new DetailsElement(page.locator("vaadin-details").first());
details.assertDisabled();
details.getSummaryLocator().click();
details.assertClosed(); // Should still be closed

Build docs developers (and LLMs) love