From 6f86784375a542548338280d1e48145d432d82ab Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Thu, 8 Oct 2026 13:10:23 -0700 Subject: [PATCH] Add helpers for getting an export option under a specific header --- .../test/components/ui/grids/ExportMenu.java | 33 +++++++++++++++++++ .../test/components/ui/grids/GridBar.java | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/org/labkey/test/components/ui/grids/ExportMenu.java b/src/org/labkey/test/components/ui/grids/ExportMenu.java index 71c2fcc8cc..a94fe0d6f5 100644 --- a/src/org/labkey/test/components/ui/grids/ExportMenu.java +++ b/src/org/labkey/test/components/ui/grids/ExportMenu.java @@ -70,6 +70,29 @@ public File exportData(GridBar.ExportType exportType, int index) return getWrapper().doAndWaitForDownload(exportButton::click); } + public File exportData(GridBar.ExportType exportType, GridBar.ExportHeaderType headerType) + { + WebElement exportButton = getExportMenuItem(exportType, headerType); + return getWrapper().doAndWaitForDownload(exportButton::click); + } + + public File exportStorageMap() + { + _menu.expand(); + WebElement exportButton = Locator.tag("li") + .withDescendant(Locator.tagWithClass("span", "export-menu-icon")) + .containing("Storage Map (Excel)") + .findElement(this); + return getWrapper().doAndWaitForDownload(exportButton::click); + } + + public TabSelectionExportDialog openExcelTabsModal(GridBar.ExportHeaderType headerType) + { + getExportMenuItem(GridBar.ExportType.EXCEL, headerType).click(); + + return new TabSelectionExportDialog(this.getDriver()); + } + public TabSelectionExportDialog openExcelTabsModal() { WebElement exportButton = getExportMenuItem(GridBar.ExportType.EXCEL); @@ -89,4 +112,14 @@ private WebElement getExportMenuItem(GridBar.ExportType exportType, int index) _menu.expand(); return Locator.css("span.export-menu-icon").withClass(exportType.buttonCssClass()).findElements(this).get(index); } + + // Header type sections are only labeled when the menu offers more than one header type + private WebElement getExportMenuItem(GridBar.ExportType exportType, GridBar.ExportHeaderType headerType) + { + _menu.expand(); + return Locator.tagWithAttribute("li", "role", "heading").containing(headerType.getSectionText()) + .followingSibling("li") + .withDescendant(Locator.tagWithClass("span", "export-menu-icon").withClass(exportType.buttonCssClass())) + .findElement(this); + } } diff --git a/src/org/labkey/test/components/ui/grids/GridBar.java b/src/org/labkey/test/components/ui/grids/GridBar.java index 92eca58ae9..4f2920e897 100644 --- a/src/org/labkey/test/components/ui/grids/GridBar.java +++ b/src/org/labkey/test/components/ui/grids/GridBar.java @@ -74,11 +74,26 @@ public File exportData(ExportType exportType, int index) return elementCache().exportMenu.exportData(exportType, index); } + public File exportData(ExportType exportType, ExportHeaderType headerType) + { + return elementCache().exportMenu.exportData(exportType, headerType); + } + + public File exportStorageMap() + { + return elementCache().exportMenu.exportStorageMap(); + } + public TabSelectionExportDialog openExcelTabsModal() { return elementCache().exportMenu.openExcelTabsModal(); } + public TabSelectionExportDialog openExcelTabsModal(ExportHeaderType headerType) + { + return elementCache().exportMenu.openExcelTabsModal(headerType); + } + /** * gets the Pager for the current grid, if it exists. * If the grid is filtered down to an empty set or if there are no loaded rows, it will not be present @@ -413,4 +428,22 @@ public Character getSeparator() return _separator; } } + + public enum ExportHeaderType + { + CAPTION("Grid View Labels"), + IMPORT_FIELD("Field Names"); + + private final String _sectionText; + + ExportHeaderType(String sectionText) + { + _sectionText = sectionText; + } + + public String getSectionText() + { + return _sectionText; + } + } }