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 aContextMenuElement from the page overlay by locating the first opened context menu.
The Playwright page instance
ContextMenuElement(Locator locator)
Create aContextMenuElement from an existing locator.
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.The element that triggers the context menu
Instance Methods
assertOpen()
Assert that the context menu overlay is open. Verifies: The element has theopened 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.The visible label of the parent menu item
ContextMenuElement - The submenu overlay element
selectItem(String itemLabel)
Select a menu item by its accessible name.The visible label of the menu item to select
assertItemDisabled(String itemLabel)
Assert that a menu item is disabled.The visible label of the menu item
assertItemEnabled(String itemLabel)
Assert that a menu item is enabled.The visible label of the menu item
assertItemChecked(String itemLabel)
Assert that a checkable menu item is checked.The visible label of the menu item
menu-item-checked attribute.
assertItemNotChecked(String itemLabel)
Assert that a checkable menu item is not checked.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
menuitemfor item lookups - Checkable items use the
menu-item-checkedattribute to indicate state - Submenus are nested
<vaadin-context-menu>elements withslot="submenu"