Skip to main content

Overview

SideNavigationElement is a Playwright wrapper for the <vaadin-side-nav> component. It provides utilities to manage collapsible navigation menus and access navigation items. Component tag: vaadin-side-nav Implements:
  • HasLabelElement

Constructors

SideNavigationElement(Locator locator)

Create a SideNavigationElement from an existing locator.
locator
Locator
required
The Playwright locator for the side navigation element

Methods

isCollapsed()

Check if the side nav is collapsed. Returns: boolean - True if the side navigation is collapsed

assertCollapsed()

Assert that the side nav is collapsed. Verifies: The element has the collapsed attribute.

assertExpanded()

Assert that the side nav is expanded. Verifies: The element does not have the collapsed attribute.

assertCollapsible()

Assert that the side nav is collapsible. Verifies: The element has the collapsible attribute.

assertNotCollapsible()

Assert that the side nav is not collapsible. Verifies: The element does not have the collapsible attribute.

getItem(String label)

Get a SideNavigationItemElement by its label text. This searches for a direct or nested vaadin-side-nav-item with the given text.
label
String
required
The label text of the navigation item
Returns: SideNavigationItemElement - The navigation item with the specified label Note: The navigation item must be visible. You may need to expand parent items first.

clickItem(String label)

Click a navigation item by its label.
label
String
required
The label text of the navigation item to click

toggle()

Toggle the expansion state of the side navigation. Clicks the label slot to collapse/expand.

getLabelLocator()

Get the locator for the side navigation label slot. Returns: Locator - Locator for the [slot='label'] element

Static Factory Methods

getByLabel(Page page, String label)

Get the SideNavigationElement by its accessible label.
page
Page
required
The Playwright page instance
label
String
required
The accessible label of the side navigation (uses ARIA role NAVIGATION)
Returns: SideNavigationElement - The side navigation with the specified label

Usage Example

import org.vaadin.addons.dramafinder.element.SideNavigationElement;
import org.vaadin.addons.dramafinder.element.SideNavigationItemElement;

// Get side navigation by label
SideNavigationElement nav = SideNavigationElement.getByLabel(page, "My App");
nav.assertVisible();

// Check collapsible state
nav.assertCollapsible();
nav.assertExpanded();

// Toggle collapse state
nav.toggle();
nav.assertCollapsed();
nav.toggle();
nav.assertExpanded();

// Get and verify label
assertEquals("My App", nav.getLabel());

// Access navigation items
SideNavigationItemElement dashboard = nav.getItem("Dashboard");
dashboard.assertVisible();
dashboard.assertEnabled();
assertEquals("Dashboard", dashboard.getLabel());

// Work with nested items
SideNavigationItemElement admin = nav.getItem("Admin");
if (!admin.isExpanded()) {
    admin.toggle();
}
admin.assertExpanded();

// Access child items after expanding parent
SideNavigationItemElement users = nav.getItem("Users");
users.assertVisible();

// Click to navigate
nav.clickItem("Dashboard");

Build docs developers (and LLMs) love