diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml
index 60086fd5895..47b37d05888 100644
--- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml
+++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml
@@ -206,7 +206,7 @@
DataEditorForm.structurePanel.selectedLogicalNode.type eq StructurePanel.VIEW_NODE_TYPE and
mediaProvider.hasPreviewVariant(DataEditorForm.galleryPanel.getGalleryMediaContent(DataEditorForm.galleryPanel.lastSelection.key))}"
icon="fa fa-external-link fa-sm"
- styleClass="plain"
+ styleClass="plain viewPageInNewWindow"
outcome="externalView"
target="_blank">
@@ -216,7 +216,7 @@
@@ -196,7 +196,7 @@
update="dialogEditDocStrucTypeDialog"/>
Browser.getDriver().findElement(By.id("logicalTree")).isDisplayed());
- // right click on first tree node representing image 2
- WebElement firstTreeNode = Browser.getDriver().findElement(
- By.cssSelector("#logicalTree\\:0_0 .ui-treenode-content")
- );
- new Actions(Browser.getDriver()).contextClick(firstTreeNode).build().perform();
-
- // wait until menu is visible
- await().ignoreExceptions().pollDelay(100, TimeUnit.MILLISECONDS).atMost(5, TimeUnit.SECONDS)
- .until(() -> Browser.getDriver().findElement(By.id("contextMenuLogicalTree")).isDisplayed());
+ // open context menu for linked page "2"
+ Pages.getMetadataEditorPage().openContextMenuForStructureTreeNode("0_0");
// click second menu entry to open new tab
- Browser.getDriver().findElement(By.cssSelector(
- "#contextMenuLogicalTree .ui-menuitem:nth-child(2) .ui-menuitem-link"
- )).click();
+ Browser.getDriver().findElement(By.cssSelector("#contextMenuLogicalTree .viewPageInNewWindow")).click();
// find handle of new tab window
String newWindowHandle = Browser.getDriver().getWindowHandles().stream()
diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java
index 9bb7819ff62..a87dea1d367 100644
--- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java
+++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MetadataEditorPage.java
@@ -251,13 +251,11 @@ public void openContextMenuForStructureTreeNode(String nodeId) {
/**
* Click on a menu entry in the structure tree context menu.
*
- * @param menuEntry the menu entry index (starting with 1)
+ * @param menuItemClassName the class name of the menu entry
*/
- public void clickStructureTreeContextMenuEntry(int menuEntry) {
+ public void clickStructureTreeContextMenuEntry(String menuItemClassName) {
// click on menu entry
- contextMenuLogicalTree.findElement(By.cssSelector(
- ".ui-menuitem:nth-child(" + menuEntry + ") .ui-menuitem-link"
- )).click();
+ contextMenuLogicalTree.findElement(By.className(menuItemClassName)).click();
// wait for context menu to disappear
await().ignoreExceptions().pollDelay(100, TimeUnit.MILLISECONDS).atMost(5, TimeUnit.SECONDS)
.until(() -> !contextMenuLogicalTree.isDisplayed());