From f98c98c7431bef0e3eb949f382bb3d9daa211e64 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 26 Jun 2025 11:25:08 -0700 Subject: [PATCH 1/2] Wait for participant report "Save" button to be enabled --- .../test/tests/ParticipantReportTest.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/org/labkey/test/tests/ParticipantReportTest.java b/src/org/labkey/test/tests/ParticipantReportTest.java index 78bc2620f6..5079ef9b47 100644 --- a/src/org/labkey/test/tests/ParticipantReportTest.java +++ b/src/org/labkey/test/tests/ParticipantReportTest.java @@ -22,6 +22,7 @@ import org.labkey.test.categories.Reports; import org.labkey.test.components.ext4.Window; import org.labkey.test.components.html.BootstrapMenu; +import org.labkey.test.util.Ext4Helper; import org.labkey.test.util.LogMethod; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -262,10 +263,12 @@ private void doParticipantReportTest() waitForElementToDisappear(Locator.xpath("id('participant-report-panel-1-body')/div[contains(@style, 'display: none')]"), WAIT_FOR_JAVASCRIPT); click(Locator.xpath("//img[@data-qtip = 'Delete']")); // Delete 'Severity Grade' column. clickButton("Save As", 0); - _extHelper.waitForExtDialog("Save As"); + Window saveAsDialog = new Window.WindowFinder(getDriver()).withTitle("Save As").waitFor(); _extHelper.setExtFormElementByLabel("Save As", "Report Name", PARTICIPANT_REPORT2_NAME); _extHelper.setExtFormElementByLabel("Save As", "Report Description", PARTICIPANT_REPORT2_DESCRIPTION); - clickButtonByIndex("Save", 1, 0); + Ext4Helper.Locators.ext4Button("Save").withoutAttributeContaining("class", "disabled") + .waitForElement(saveAsDialog, 2_000).click(); + saveAsDialog.waitForClose(); _ext4Helper.waitForComponentNotDirty("participant-report-panel-1"); waitForTextToDisappear("Severity Grade"); @@ -273,14 +276,17 @@ private void doParticipantReportTest() click(Locator.xpath("//a[./span[@title = 'Edit']]")); waitForElementToDisappear(Locator.xpath("id('participant-report-panel-1-body')/div[contains(@style, 'display: none')]"), WAIT_FOR_JAVASCRIPT); clickButton("Save As", 0); - _extHelper.waitForExtDialog("Save As"); + saveAsDialog = new Window.WindowFinder(getDriver()).withTitle("Save As").waitFor(); _extHelper.setExtFormElementByLabel("Save As", "Report Name", PARTICIPANT_REPORT_NAME); _extHelper.setExtFormElementByLabel("Save As", "Report Description", PARTICIPANT_REPORT2_DESCRIPTION); - clickButtonByIndex("Save", 1, 0); - _extHelper.waitForExtDialog("Failure"); + Ext4Helper.Locators.ext4Button("Save").withoutAttributeContaining("class", "disabled") + .waitForElement(saveAsDialog, 2_000).click(); + Window failureDialog = new Window.WindowFinder(getDriver()).withTitle("Failure").waitFor(); assertTextPresent("Another report with the same name already exists."); clickButton("OK", 0); + failureDialog.waitForClose(); clickButton("Cancel", 0); // Verify cancel button. + saveAsDialog.waitForClose(); waitForElement(Locator.xpath("id('participant-report-panel-1-body')/div[contains(@style, 'display: none')]"), WAIT_FOR_JAVASCRIPT); // Edit panel should be hidden @@ -350,12 +356,12 @@ private void doParticipantReportTest() { assertTextPresent(ptid); - String base = "//td//a[text()='" + ptid + "']/../../..//td[contains(text(), 'Groups:')]/following-sibling::td[contains(normalize-space(), '"; - waitForElement(Locator.xpath(base + PARTICIPANT_GROUP_ONE + "')]")); + Locator.XPathLocator base = Locator.xpath("//td//a[text()='" + ptid + "']/../../..//td[contains(text(), 'Groups:')]/following-sibling::td"); + waitForElement(base.containing(PARTICIPANT_GROUP_ONE)); if (ptid_list2.contains(ptid)) { - assertElementPresent(Locator.xpath(base + PARTICIPANT_GROUP_TWO + "')]")); + assertElementPresent(base.containing(PARTICIPANT_GROUP_TWO)); } } From 098e319341388a822388a04d219a5730c99f5dd9 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 26 Jun 2025 11:28:51 -0700 Subject: [PATCH 2/2] Use existing locator to find enabled button --- src/org/labkey/test/tests/ParticipantReportTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/org/labkey/test/tests/ParticipantReportTest.java b/src/org/labkey/test/tests/ParticipantReportTest.java index 5079ef9b47..c7e1d9de5f 100644 --- a/src/org/labkey/test/tests/ParticipantReportTest.java +++ b/src/org/labkey/test/tests/ParticipantReportTest.java @@ -266,8 +266,7 @@ private void doParticipantReportTest() Window saveAsDialog = new Window.WindowFinder(getDriver()).withTitle("Save As").waitFor(); _extHelper.setExtFormElementByLabel("Save As", "Report Name", PARTICIPANT_REPORT2_NAME); _extHelper.setExtFormElementByLabel("Save As", "Report Description", PARTICIPANT_REPORT2_DESCRIPTION); - Ext4Helper.Locators.ext4Button("Save").withoutAttributeContaining("class", "disabled") - .waitForElement(saveAsDialog, 2_000).click(); + Ext4Helper.Locators.ext4ButtonEnabled("Save").waitForElement(saveAsDialog, 2_000).click(); saveAsDialog.waitForClose(); _ext4Helper.waitForComponentNotDirty("participant-report-panel-1"); waitForTextToDisappear("Severity Grade"); @@ -279,8 +278,7 @@ private void doParticipantReportTest() saveAsDialog = new Window.WindowFinder(getDriver()).withTitle("Save As").waitFor(); _extHelper.setExtFormElementByLabel("Save As", "Report Name", PARTICIPANT_REPORT_NAME); _extHelper.setExtFormElementByLabel("Save As", "Report Description", PARTICIPANT_REPORT2_DESCRIPTION); - Ext4Helper.Locators.ext4Button("Save").withoutAttributeContaining("class", "disabled") - .waitForElement(saveAsDialog, 2_000).click(); + Ext4Helper.Locators.ext4ButtonEnabled("Save").waitForElement(saveAsDialog, 2_000).click(); Window failureDialog = new Window.WindowFinder(getDriver()).withTitle("Failure").waitFor(); assertTextPresent("Another report with the same name already exists."); clickButton("OK", 0);