Skip to main content

Overview

MenuElement is a Playwright wrapper for the menu overlay list <vaadin-menu-bar-list-box>. It represents submenu overlays that appear when menu items are clicked. Component tag: vaadin-menu-bar-list-box Implements:
  • HasThemeElement
  • HasStyleElement
  • HasAriaLabelElement

Constructors

Create a MenuElement from the page by locating the first <vaadin-menu-bar-list-box> element.
page
Page
required
The Playwright page instance
Create a MenuElement from an existing locator.
locator
Locator
required
The Playwright locator for the menu overlay element

Methods

getMenuItemElement(String name)

Get a menu item by its visible label within this menu overlay.
name
String
required
The visible label text of the menu item
Returns: MenuItemElement - The menu item element with the specified label

openSubMenu(String name)

Click a menu item to open its submenu and return the next overlay.
name
String
required
The visible label text of the menu item that contains a submenu
Returns: MenuElement - The opened nested submenu overlay

Static Factory Methods

getByLabel(Page page, String label)

Get a menu overlay by its accessible label (ARIA label).
page
Page
required
The Playwright page instance
label
String
required
The accessible label of the menu overlay (uses ARIA role MENU)
Returns: MenuElement - The menu overlay with the specified label

Usage Example

import org.vaadin.addons.dramafinder.element.MenuBarElement;
import org.vaadin.addons.dramafinder.element.MenuElement;
import org.vaadin.addons.dramafinder.element.MenuItemElement;

// Open a submenu from menu bar
MenuBarElement menuBar = new MenuBarElement(page);
MenuElement shareMenu = menuBar.openSubMenu("Share");

// Access items in the submenu
MenuItemElement emailItem = shareMenu.getMenuItemElement("By email");
emailItem.click();

// Open nested submenu
MenuElement socialMenu = shareMenu.openSubMenu("On social media");
MenuItemElement facebookItem = socialMenu.getMenuItemElement("Facebook");
facebookItem.click();

Build docs developers (and LLMs) love