Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Working with Context Menu

Mikołaj Mański edited this page Jul 26, 2016 · 2 revisions

Working with Context Menu

Getting Context Menu using parsys

Let's say that we want to perform some action by selecting an option from the context menu. How to do that? Here's an example:

  @Test
  public void editComponentFromContextMenu() {
    SectionHeaderComponent sectionHeaderComponent = parsys.insertComponent(SectionHeaderComponent.class);
    AemContextMenu contextMenu = parsys.openContextMenuFirstComponent(SectionHeaderComponent.class);
    contextMenu.clickOption(MenuOption.EDIT);
    sectionHeaderComponent.getDialog().ok();
  }

In the first line we are inserting our SectionHeaderComponent into parsys. If you don't know how to find and use parsys on the page, please refer to Finding a parsys tutorial where we defined it in this class. Then we are obtaining AemContextMenu from first component in the parsys (you can select also n-th component if you want, but in this case we are inserting only one component to the empty parsys). Using obtained AemContextMenu instance we can click on desired option using MenuOption enum.

Context Menu

As the click action on Edit option causes dialog window to open - we can get it form the component's instance and click OK button to close it.

Getting started with Bobcat

  1. Getting started

AEM Related Features

  1. Authoring tutorial - Classic
  1. AEM Classic Authoring Advanced usage
  1. Authoring tutorial - Touch UI
Clone this wiki locally