Skip to main content

Overview

ContextMenuElement is a Playwright wrapper for context menu overlays <vaadin-context-menu-overlay>. It provides helpers to open a menu via a context-click on the target, inspect the overlay list box, and pick menu items by their accessible label. Component tag: vaadin-context-menu Implements:
  • HasStyleElement

Constructors

ContextMenuElement(Page page)

Create a ContextMenuElement from the page overlay by locating the first opened context menu.
Page
required
The Playwright page instance

ContextMenuElement(Locator locator)

Create a ContextMenuElement from an existing locator.
Locator
required
The Playwright locator for the context menu element

Static Methods

openOn(Locator target)

Open the context menu by invoking a context-click (right-click) on the provided target element.
Locator
required
The element that triggers the context menu

Instance Methods

assertOpen()

Assert that the context menu overlay is open. Verifies: The element has the opened attribute.

assertClosed()

Assert that the context menu overlay is closed or hidden. Verifies: The element is hidden in the DOM.

openSubMenu(String itemLabel)

Open a submenu and return its overlay.
String
required
The visible label of the parent menu item
Returns: ContextMenuElement - The submenu overlay element

selectItem(String itemLabel)

Select a menu item by its accessible name.
String
required
The visible label of the menu item to select

assertItemDisabled(String itemLabel)

Assert that a menu item is disabled.
String
required
The visible label of the menu item

assertItemEnabled(String itemLabel)

Assert that a menu item is enabled.
String
required
The visible label of the menu item

assertItemChecked(String itemLabel)

Assert that a checkable menu item is checked.
String
required
The visible label of the menu item
Verifies: The item has the menu-item-checked attribute.

assertItemNotChecked(String itemLabel)

Assert that a checkable menu item is not checked.
String
required
The visible label of the menu item

getListBoxLocator()

Get the locator for the context menu list box. Returns: Locator - Locator for <vaadin-context-menu-list-box>

Usage Example

Notes

  • The context menu uses ARIA role menuitem for item lookups
  • Checkable items use the menu-item-checked attribute to indicate state
  • Submenus are nested <vaadin-context-menu> elements with slot="submenu"