From cd3ead5d56c0a227848b2566b774d7aa7f39196f Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:25:26 +0530 Subject: [PATCH 01/14] Added java memory heap size --- build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6124f8545..bd9efec3f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,11 @@ def lsp4ijVersion = '0.7.0' allprojects { sourceCompatibility = javaVersion targetCompatibility = javaVersion - tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } + tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' + options.fork = true + options.forkOptions.memoryMaximumSize = "4g" + } } repositories { From 3c272d3e0e8e2f676b3372a5562b584a38ac82dd Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:28:27 +0530 Subject: [PATCH 02/14] Handled null pointer exception --- src/test/java/io/openliberty/tools/intellij/it/TestUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java index 8e5ce4244..4aba7ee90 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java @@ -577,6 +577,10 @@ public static void copyDirectory(String sourceDirectoryLocation, String destinat */ public static void detectFatalError() { final String outputFile = System.getenv("JUNIT_OUTPUT_TXT"); + if (outputFile == null) { + System.err.println("ERROR: Environment variable 'JUNIT_OUTPUT_TXT' is not set."); + return; // Exit the method gracefully or handle the missing file scenario + } try { final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(outputFile))); // Flush our output and then wait briefly for the process running 'tee' to flush output to the From dbab587b8f22a075f155052170f080b10bdf2e52 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:58:51 +0530 Subject: [PATCH 03/14] UI changes for mac after integrating other OS change --- .../it/SingleModMPProjectTestCommon.java | 7 +- .../tools/intellij/it/UIBotTestUtils.java | 283 ++++++++++++------ .../it/fixtures/ProjectFrameFixture.java | 69 +++++ 3 files changed, 260 insertions(+), 99 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index 5844d1aac..186e48ac8 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -1149,7 +1149,12 @@ public static void prepareEnv(String projectPath, String projectName) { // Closing the build file editor here prevents it from opening automatically when the project // in the Liberty tool window is clicked or right-clicked again. This is done on purpose to // prevent false negative tests related to the build file editor tab. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + if (remoteRobot.isMac()) { + UIBotTestUtils.closeAllEditorTabs(remoteRobot); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + } TestUtils.printTrace(TestUtils.TraceSevLevel.INFO, "prepareEnv. Exit. ProjectName: " + projectName); diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index a86ac3f6f..ba6e5b3a7 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -22,6 +22,8 @@ import org.assertj.swing.core.MouseButton; import org.junit.Assert; import org.junit.jupiter.api.Assertions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.awt.*; import java.awt.event.KeyEvent; @@ -47,6 +49,8 @@ */ public class UIBotTestUtils { + private static final Logger log = LoggerFactory.getLogger(UIBotTestUtils.class); + /** * Print destination types. */ @@ -120,11 +124,16 @@ public static void importProject(RemoteRobot remoteRobot, String projectsPath, S // From the project frame. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); commonFixture = projectFrame; - clickOnMainMenu(remoteRobot); - ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); - fileMenuEntry.moveMouse(); - ComponentFixture openFixture = projectFrame.getActionMenuItem("Open..."); - openFixture.click(new Point()); + + if (remoteRobot.isMac()) { + handleMenuBasedOnVersion(remoteRobot, "File", "Open...", "Open…"); + } else { + clickOnMainMenu(remoteRobot); + ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); + fileMenuEntry.moveMouse(); + ComponentFixture openFixture = projectFrame.getActionMenuItem("Open..."); + openFixture.click(new Point()); + } } // Specify the project's path. The text field is pre-populated by default. @@ -209,17 +218,22 @@ public static DialogFixture getOpenProjectLocationDialog(CommonContainerFixture public static void closeProjectFrame(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); // minimize windows os intellij ide to default state - if (remoteRobot.isWin()) { - minimizeWindow(remoteRobot); + if (remoteRobot.isMac()) { + projectFrame.clickOnMainMenuWithActions(remoteRobot, "File", "Close Project"); } - clickOnMainMenu(remoteRobot); - // Click on File on the Menu bar. - ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); - fileMenuEntry.moveMouse(); + else { + if (remoteRobot.isWin()) { + minimizeWindow(remoteRobot); + } + clickOnMainMenu(remoteRobot); + // Click on File on the Menu bar. + ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); + fileMenuEntry.moveMouse(); - // Click on Close Project in the menu. - ComponentFixture closeFixture = projectFrame.getActionMenuItem("Close Project"); - closeFixture.click(); + // Click on Close Project in the menu. + ComponentFixture closeFixture = projectFrame.getActionMenuItem("Close Project"); + closeFixture.click(); + } } /** @@ -746,18 +760,7 @@ public static void closeFileEditorTab(RemoteRobot remoteRobot, String editorTabN */ public static void closeAllEditorTabs(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - ComponentFixture windowMenuEntry = projectFrame.getActionMenu("Window", "10"); - windowMenuEntry.click(); - - // Click on Editor Tabs in the menu. - ComponentFixture editorTabsFixture = projectFrame.getChildActionMenu("Window", "Editor Tabs"); - editorTabsFixture.click(); - - // Click on Close Project in the menu. - ComponentFixture closeAllTabsFixture = projectFrame.getChildActionMenuItem("Window", "Close All Tabs"); - if (closeAllTabsFixture.callJs("component.isEnabled();", false)) { - closeAllTabsFixture.click(); - } + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", "Close All Tabs"); } /** @@ -789,7 +792,7 @@ public static void clickOnFileTab(RemoteRobot remoteRobot, String fileName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); try { - String xPath = "//div[@accessiblename='" + fileName + "' and @class='SimpleColoredComponent']"; + String xPath = "//div[@accessiblename='" + fileName + "' and @class='EditorTabLabel']"; ComponentFixture actionButton = projectFrame.getActionButton(xPath, "10"); actionButton.click(); @@ -1446,19 +1449,29 @@ public static void chooseQuickFix(RemoteRobot remoteRobot, String quickfixChoose public static void copyWindowContent(RemoteRobot remoteRobot) { // Select the content. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - clickOnMainMenu(remoteRobot); - ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); - editMenuEntry.moveMouse(); - ComponentFixture slectAllEntry = projectFrame.getActionMenuItem("Select All"); - slectAllEntry.click(); + if (remoteRobot.isMac()) { + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); + editMenuEntry.moveMouse(); + ComponentFixture slectAllEntry = projectFrame.getActionMenuItem("Select All"); + slectAllEntry.click(); + } // Copy the content. - clickOnMainMenu(remoteRobot); - ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); - editMenuEntryNew.moveMouse(); - ComponentFixture copyEntry = projectFrame.getActionMenuItem("Copy"); - copyEntry.click(); - projectFrame.click(); + if (remoteRobot.isMac()) { + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Copy"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); + editMenuEntryNew.moveMouse(); + ComponentFixture copyEntry = projectFrame.getActionMenuItem("Copy"); + copyEntry.click(); + projectFrame.click(); + } } /** @@ -1467,20 +1480,24 @@ public static void copyWindowContent(RemoteRobot remoteRobot) { * @param remoteRobot The RemoteRobot instance. */ public static void clearWindowContent(RemoteRobot remoteRobot) { - // Select the content. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - clickOnMainMenu(remoteRobot); - ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); - editMenuEntry.moveMouse(); - ComponentFixture selectAllEntry = projectFrame.getActionMenuItem("Select All"); - selectAllEntry.click(); - - // Delete/Clear the content. - clickOnMainMenu(remoteRobot); - ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); - editMenuEntryNew.moveMouse(); - ComponentFixture deleteEntry = projectFrame.getActionMenuItem("Delete"); - deleteEntry.click(); + // Select the content. + if (remoteRobot.isMac()) { + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Delete"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); + editMenuEntry.moveMouse(); + ComponentFixture selectAllEntry = projectFrame.getActionMenuItem("Select All"); + selectAllEntry.click(); + clickOnMainMenu(remoteRobot); + ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); + editMenuEntryNew.moveMouse(); + ComponentFixture deleteEntry = projectFrame.getActionMenuItem("Delete"); + deleteEntry.click(); + } } public static void pasteOnActiveWindow(RemoteRobot remoteRobot) { @@ -1502,27 +1519,30 @@ public static void pasteOnActiveWindow(RemoteRobot remoteRobot, boolean homeCurs } // Select the content. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - clickOnMainMenu(remoteRobot); - ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); - editMenuEntry.moveMouse(); - ComponentFixture selectAllEntry = projectFrame.getActionMenuItem("Select All"); - selectAllEntry.click(); - - // Paste the content. - clickOnMainMenu(remoteRobot); - editMenuEntry = projectFrame.getActionMenu("Edit", "10"); - editMenuEntry.moveMouse(); - ComponentFixture pasteFixture = projectFrame.getChildActionMenu("Edit", "Paste"); - pasteFixture.click(); - ComponentFixture pasteChildEntry = projectFrame.getChildActionMenuItem("Edit", "Paste"); - pasteChildEntry.click(); - - // Save. - clickOnMainMenu(remoteRobot); - ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); - fileMenuEntry.moveMouse(); - ComponentFixture saveAllEntry = projectFrame.getActionMenuItem("Save All"); - saveAllEntry.click(); + if (remoteRobot.isMac()) { + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Paste", "Paste"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "File", "Save All"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); + editMenuEntry.moveMouse(); + ComponentFixture selectAllEntry = projectFrame.getActionMenuItem("Select All"); + selectAllEntry.click(); + clickOnMainMenu(remoteRobot); + editMenuEntry = projectFrame.getActionMenu("Edit", "10"); + editMenuEntry.moveMouse(); + ComponentFixture pasteFixture = projectFrame.getChildActionMenu("Edit", "Paste"); + pasteFixture.click(); + ComponentFixture pasteChildEntry = projectFrame.getChildActionMenuItem("Edit", "Paste"); + pasteChildEntry.click(); + clickOnMainMenu(remoteRobot); + ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); + fileMenuEntry.moveMouse(); + ComponentFixture saveAllEntry = projectFrame.getActionMenuItem("Save All"); + saveAllEntry.click(); + } } /** @@ -1635,13 +1655,18 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S // Click on Navigate on the Menu bar. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2)); - clickOnMainMenu(remoteRobot); - ComponentFixture navigateMenuEntry = projectFrame.getActionMenu("Navigate", "20"); - navigateMenuEntry.moveMouse(); - - // Click on Search Everywhere in the menu. - ComponentFixture searchFixture = projectFrame.getActionMenuItem("Search Everywhere"); - searchFixture.click(); + if (remoteRobot.isMac()) { + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Navigate", "Search Everywhere"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture navigateMenuEntry = projectFrame.getActionMenu("Navigate", "20"); + navigateMenuEntry.moveMouse(); + + // Click on Search Everywhere in the menu. + ComponentFixture searchFixture = projectFrame.getActionMenuItem("Search Everywhere"); + searchFixture.click(); + } // Click on the Actions tab ComponentFixture actionsTabFixture = projectFrame.getSETabLabel("Actions"); @@ -1913,11 +1938,16 @@ public static void respondToRemoveProjectQueryDialog(RemoteRobot remoteRobot) { */ public static void createLibertyConfiguration(RemoteRobot remoteRobot, String cfgName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - clickOnMainMenu(remoteRobot); - ComponentFixture runMenu = projectFrame.getActionMenu("Run", "10"); - runMenu.moveMouse(); - ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem("Edit Configurations…"); - editCfgsMenuEntry.click(); + if (remoteRobot.isMac()) { + handleMenuBasedOnVersion(remoteRobot, "Run", "Edit Configurations...", "Edit Configurations…"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture runMenu = projectFrame.getActionMenu("Run", "10"); + runMenu.moveMouse(); + ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem("Edit Configurations…"); + editCfgsMenuEntry.click(); + } // Find the Run/Debug Configurations dialog. DialogFixture addProjectDialog = projectFrame.find(DialogFixture.class, @@ -2168,15 +2198,34 @@ public static void selectConfigUsingToolbar(RemoteRobot remoteRobot, String cfgN */ public static void selectConfigUsingMenu(RemoteRobot remoteRobot, String cfgName, ExecMode execMode) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - clickOnMainMenu(remoteRobot); - ComponentFixture menuOption = projectFrame.getActionMenu("Run", "10"); - menuOption.moveMouse(); - ComponentFixture menuCfgExecOption = projectFrame.getActionMenuItem("Run…"); - if (execMode == ExecMode.DEBUG) { - menuCfgExecOption = projectFrame.getActionMenuItem("Debug…"); + if (remoteRobot.isMac()) { + for (int attempt = 0; attempt < 5; attempt++) { // Retry up to 5 times + try { + handleMenuBasedOnVersion(remoteRobot, "Run", execMode == ExecMode.DEBUG ? "Debug..." : "Run...", execMode == ExecMode.DEBUG ? "Debug…" : "Run…"); + // Exit loop if successful + break; + } catch (WaitForConditionTimeoutException e) { + System.err.println("Attempt " + (attempt + 1) + " failed: Timeout while trying to find or interact with menu items."); + } catch (Exception e) { + System.err.println("Attempt " + (attempt + 1) + " failed: " + e.getMessage()); + } + + if (attempt == 4) { // If the last attempt fails + throw new IllegalStateException("Failed to perform menu navigation after multiple attempts."); + } + } } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture menuOption = projectFrame.getActionMenu("Run", "10"); + menuOption.moveMouse(); + ComponentFixture menuCfgExecOption = projectFrame.getActionMenuItem("Run…"); + if (execMode == ExecMode.DEBUG) { + menuCfgExecOption = projectFrame.getActionMenuItem("Debug…"); + } - menuCfgExecOption.click(); + menuCfgExecOption.click(); + } // Retrieve the list of configs from the config list window. ComponentFixture cfgSelectWindow = projectFrame.getMyList(); @@ -2200,7 +2249,7 @@ public static void selectConfigUsingMenu(RemoteRobot remoteRobot, String cfgName public static void runConfigUsingIconOnToolbar(RemoteRobot remoteRobot, ExecMode execMode) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - Locator locator = byXpath("//div[contains(@myaction.key, 'group.RunMenu.text')]"); + Locator locator = byXpath("//div[@class='ActionButton' and @myaction='Run (Run selected configuration)']"); if (execMode == ExecMode.DEBUG) { locator = byXpath("//div[@myicon='debug.svg']"); } @@ -2222,11 +2271,16 @@ public static void runConfigUsingIconOnToolbar(RemoteRobot remoteRobot, ExecMode */ public static void deleteLibertyRunConfigurations(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - clickOnMainMenu(remoteRobot); - ComponentFixture runMenu = projectFrame.getActionMenu("Run", "10"); - runMenu.moveMouse(); - ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem("Edit Configurations…"); - editCfgsMenuEntry.click(); + if (remoteRobot.isMac()) { + handleMenuBasedOnVersion(remoteRobot, "Run", "Edit Configurations...", "Edit Configurations…"); + } + else { + clickOnMainMenu(remoteRobot); + ComponentFixture runMenu = projectFrame.getActionMenu("Run", "10"); + runMenu.moveMouse(); + ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem("Edit Configurations…"); + editCfgsMenuEntry.click(); + } // The Run/Debug configurations dialog could resize and reposition icons. Retry in case of a failure. int maxRetries = 3; @@ -2564,7 +2618,12 @@ public static void findWelcomeFrame(RemoteRobot remoteRobot) { } catch (WaitForConditionTimeoutException e) { // If the welcome frame is not found then there is a project loaded. // Close the editor files and close the project to get back to the welcome frame. - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + if (remoteRobot.isMac()) { + UIBotTestUtils.closeAllEditorTabs(remoteRobot); + } + else { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); + } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); TestUtils.sleepAndIgnoreException(30); // takes about 15s to render the whole Welcome page including the Open button on Mac. @@ -2639,4 +2698,32 @@ public static void minimizeWindow(RemoteRobot remoteRobot) { keyboard.hotKey(VK_WINDOWS, VK_DOWN); keyboard.enter(); } + /** + * Handles version-specific menu actions based on the IntelliJ IDEA version. + * + * @param remoteRobot Instance of the RemoteRobot to interact with the IntelliJ UI. + * @param menuAction1 The name of the menu item (e.g., "Run"). + * @param menuAction2024_2 The submenu option for IntelliJ version 2024.2. + * @param menuAction2024_3 The submenu option for IntelliJ version 2024.3. + * @throws UnsupportedOperationException if the IntelliJ version is not supported. + */ + public static void handleMenuBasedOnVersion(RemoteRobot remoteRobot, String menuAction1, String menuAction2024_2, String menuAction2024_3) { + // Using Remote robot's javascript API Retrieve the IntelliJ version + String intellijVersion = remoteRobot.callJs("com.intellij.openapi.application.ApplicationInfo.getInstance().getFullVersion();"); + + String menuAction2; + if (intellijVersion.startsWith("2024.2")) { + menuAction2 = menuAction2024_2; + } else if (intellijVersion.startsWith("2024.3")) { + menuAction2 = menuAction2024_3; + } else { + // If the version is unsupported, throw an exception to indicate the issue. + throw new UnsupportedOperationException("Unsupported IntelliJ version: " + intellijVersion); + } + + // Perform the menu navigation ny locating project frame using the determined submenu option. + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + projectFrame.clickOnMainMenuWithActions(remoteRobot, menuAction1, menuAction2); + } + } diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index 28d069670..e50f3b489 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -14,7 +14,9 @@ import com.intellij.remoterobot.fixtures.*; import com.intellij.remoterobot.search.locators.Locator; import com.intellij.remoterobot.utils.RepeatUtilsKt; +import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.intellij.ui.HyperlinkLabel; +import io.openliberty.tools.intellij.it.TestUtils; import org.jetbrains.annotations.NotNull; import java.time.Duration; @@ -354,4 +356,71 @@ public ComponentFixture getRunConfigurationsComboBoxButton() { public boolean isComponentEnabled(ComponentFixture component) { return component.callJs("component.isEnabled();", false); } + /** + * Attempts to find and click the "Main Menu" button in the project frame. + * If the button is not found within the timeout, an error message is logged. + * @param remoteRobot the instance used to interact with the UI. + * + */ + public void clickOnMainMenu(RemoteRobot remoteRobot) { + ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + try { + var menuButton = projectFrame.find(ComponentFixture.class, byXpath("//div[@tooltiptext='Main Menu']"), Duration.ofSeconds(30)); + menuButton.click(); + } catch (WaitForConditionTimeoutException e) { + System.err.println("ERROR: Main menu button not found within the given timeout."); + + } + } + /** + * Clicks on the main menu and navigates through a sequence of menu actions. + * + * @param remoteRobot the instance used to interact with the UI. + * @param actions the sequence of actions to be performed in the menu hierarchy. + */ + public void clickOnMainMenuWithActions(RemoteRobot remoteRobot, String... actions) { + boolean actionPerformed = false; // Flag to indicate success + + for (int attempt = 0; attempt < 5; attempt++) { + try { + clickOnMainMenu(remoteRobot); + + List currentMenuPopup = findAll(ContainerFixture.class, byXpath("//div[@class='HeavyWeightWindow']")); + for (int i = 0; i < actions.length; i++) { + // Wait for the menu to be displayed + List finalCurrentMenuPopup = currentMenuPopup; + RepeatUtilsKt.waitFor( + Duration.ofSeconds(30), + Duration.ofSeconds(1), + "Waiting for menu " + (i + 1) + " to get displayed", + "Timeout while trying to find or interact with menu " + (i + 1) + " items.", + () -> !finalCurrentMenuPopup.isEmpty()); + + // Move the mouse or click on the desired menu item + if (i < actions.length - 1) { + currentMenuPopup.get(0).findText(actions[i]).moveMouse(); + } else { + currentMenuPopup.get(0).findText(actions[i]).click(); + } + + TestUtils.sleepAndIgnoreException(3); + + // Find the next menu popup for further actions + if (i < actions.length - 1) { + currentMenuPopup = currentMenuPopup.get(0).findAll(ContainerFixture.class, byXpath("//div[@class='HeavyWeightWindow']")); + } + } + actionPerformed = true; // Mark as successful + break; // Exit loop if successful + } catch (WaitForConditionTimeoutException e) { + System.err.println("Attempt " + (attempt + 1) + " failed: Timeout while trying to find or interact with menu items."); + } catch (Exception e) { + System.err.println("Attempt " + (attempt + 1) + " failed: " + e.getMessage()); + } + } + + if (!actionPerformed) { + throw new IllegalStateException("Failed to perform the menu actions after multiple attempts."); + } + } } From 21cf13decfcf21a354864c26a11259e869da91e0 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:30:44 +0530 Subject: [PATCH 04/14] Disabled compact mode enable feature in mac and added 2024.2 support changes for windows and linux --- .../it/SingleModLibertyLSTestCommon.java | 8 +++- .../intellij/it/SingleModMPLSTestCommon.java | 8 +++- .../it/SingleModMPProjectTestCommon.java | 8 +++- .../it/SingleModNLTRestProjectTestCommon.java | 8 +++- .../tools/intellij/it/UIBotTestUtils.java | 46 ++++++++++--------- 5 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java index 7eb5e1b66..48e9b2d59 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java @@ -62,7 +62,9 @@ public static void cleanup() { UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.xml", "5"); UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.env", "5"); UIBotTestUtils.closeFileEditorTab(remoteRobot, "bootstrap.properties", "5"); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); UIBotTestUtils.validateProjectFrameClosed(remoteRobot); @@ -400,7 +402,9 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java index 6cede1481..590c9da03 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java @@ -66,7 +66,9 @@ public static void cleanup() { UIBotTestUtils.closeFileEditorTab(remoteRobot, "ServiceLiveHealthCheck.java", "5"); UIBotTestUtils.closeFileEditorTab(remoteRobot, "microprofile-config.properties", "5"); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); UIBotTestUtils.validateProjectFrameClosed(remoteRobot); @@ -329,7 +331,9 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index 186e48ac8..1b221fa09 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -294,7 +294,9 @@ public static void cleanup() { */ protected static void closeProjectView() { UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -1136,7 +1138,9 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.findWelcomeFrame(remoteRobot); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openAndValidateLibertyToolWindow(remoteRobot, projectName); diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java index 585b10b4c..5fb15e38c 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java @@ -84,7 +84,9 @@ public void afterEach(TestInfo info) { */ @AfterAll public static void cleanup() { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); UIBotTestUtils.closeProjectView(remoteRobot); UIBotTestUtils.closeProjectFrame(remoteRobot); @@ -299,7 +301,9 @@ public static void prepareEnv(String projectPath, String projectName) { UIBotTestUtils.findWelcomeFrame(remoteRobot); UIBotTestUtils.importProject(remoteRobot, projectPath, projectName); UIBotTestUtils.openProjectView(remoteRobot); - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); + } // IntelliJ does not start building and indexing until the Project View is open UIBotTestUtils.waitForIndexing(remoteRobot); UIBotTestUtils.openLibertyToolWindow(remoteRobot); diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index ba6e5b3a7..a5df3d129 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -124,14 +124,16 @@ public static void importProject(RemoteRobot remoteRobot, String projectsPath, S // From the project frame. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); commonFixture = projectFrame; - + String openAction = null; if (remoteRobot.isMac()) { - handleMenuBasedOnVersion(remoteRobot, "File", "Open...", "Open…"); + openAction = handleMenuBasedOnVersion(remoteRobot, "Open...", "Open…"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "File", openAction); } else { clickOnMainMenu(remoteRobot); ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); fileMenuEntry.moveMouse(); - ComponentFixture openFixture = projectFrame.getActionMenuItem("Open..."); + openAction = handleMenuBasedOnVersion(remoteRobot, "Open...", "Open…"); + ComponentFixture openFixture = projectFrame.getActionMenuItem(openAction); openFixture.click(new Point()); } } @@ -1451,6 +1453,7 @@ public static void copyWindowContent(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); if (remoteRobot.isMac()) { projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Copy"); } else { clickOnMainMenu(remoteRobot); @@ -1458,13 +1461,7 @@ public static void copyWindowContent(RemoteRobot remoteRobot) { editMenuEntry.moveMouse(); ComponentFixture slectAllEntry = projectFrame.getActionMenuItem("Select All"); slectAllEntry.click(); - } - // Copy the content. - if (remoteRobot.isMac()) { - projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Copy"); - } - else { clickOnMainMenu(remoteRobot); ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); editMenuEntryNew.moveMouse(); @@ -1938,14 +1935,17 @@ public static void respondToRemoveProjectQueryDialog(RemoteRobot remoteRobot) { */ public static void createLibertyConfiguration(RemoteRobot remoteRobot, String cfgName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + String editConfigurationAction= null; if (remoteRobot.isMac()) { - handleMenuBasedOnVersion(remoteRobot, "Run", "Edit Configurations...", "Edit Configurations…"); + editConfigurationAction = handleMenuBasedOnVersion(remoteRobot, "Edit Configurations...", "Edit Configurations…"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Run", editConfigurationAction); } else { clickOnMainMenu(remoteRobot); ComponentFixture runMenu = projectFrame.getActionMenu("Run", "10"); runMenu.moveMouse(); - ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem("Edit Configurations…"); + editConfigurationAction = handleMenuBasedOnVersion(remoteRobot, "Edit Configurations...", "Edit Configurations…"); + ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem(editConfigurationAction); editCfgsMenuEntry.click(); } @@ -2198,10 +2198,12 @@ public static void selectConfigUsingToolbar(RemoteRobot remoteRobot, String cfgN */ public static void selectConfigUsingMenu(RemoteRobot remoteRobot, String cfgName, ExecMode execMode) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + String debugOrRunAction = null; if (remoteRobot.isMac()) { for (int attempt = 0; attempt < 5; attempt++) { // Retry up to 5 times try { - handleMenuBasedOnVersion(remoteRobot, "Run", execMode == ExecMode.DEBUG ? "Debug..." : "Run...", execMode == ExecMode.DEBUG ? "Debug…" : "Run…"); + debugOrRunAction = handleMenuBasedOnVersion(remoteRobot, execMode == ExecMode.DEBUG ? "Debug..." : "Run...", execMode == ExecMode.DEBUG ? "Debug…" : "Run…"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Run", debugOrRunAction); // Exit loop if successful break; } catch (WaitForConditionTimeoutException e) { @@ -2219,9 +2221,11 @@ public static void selectConfigUsingMenu(RemoteRobot remoteRobot, String cfgName clickOnMainMenu(remoteRobot); ComponentFixture menuOption = projectFrame.getActionMenu("Run", "10"); menuOption.moveMouse(); - ComponentFixture menuCfgExecOption = projectFrame.getActionMenuItem("Run…"); + debugOrRunAction= handleMenuBasedOnVersion(remoteRobot, "Run...", "Run…"); + ComponentFixture menuCfgExecOption = projectFrame.getActionMenuItem(debugOrRunAction); if (execMode == ExecMode.DEBUG) { - menuCfgExecOption = projectFrame.getActionMenuItem("Debug…"); + debugOrRunAction = handleMenuBasedOnVersion(remoteRobot, "Debug...", "Debug…"); + menuCfgExecOption = projectFrame.getActionMenuItem(debugOrRunAction); } menuCfgExecOption.click(); @@ -2271,14 +2275,17 @@ public static void runConfigUsingIconOnToolbar(RemoteRobot remoteRobot, ExecMode */ public static void deleteLibertyRunConfigurations(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + String editConfigurationAction = null; if (remoteRobot.isMac()) { - handleMenuBasedOnVersion(remoteRobot, "Run", "Edit Configurations...", "Edit Configurations…"); + editConfigurationAction = handleMenuBasedOnVersion(remoteRobot, "Edit Configurations...", "Edit Configurations…"); + projectFrame.clickOnMainMenuWithActions(remoteRobot, "Run", editConfigurationAction); } else { clickOnMainMenu(remoteRobot); ComponentFixture runMenu = projectFrame.getActionMenu("Run", "10"); runMenu.moveMouse(); - ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem("Edit Configurations…"); + editConfigurationAction = handleMenuBasedOnVersion(remoteRobot, "Edit Configurations...", "Edit Configurations…"); + ComponentFixture editCfgsMenuEntry = projectFrame.getActionMenuItem(editConfigurationAction); editCfgsMenuEntry.click(); } @@ -2702,12 +2709,11 @@ public static void minimizeWindow(RemoteRobot remoteRobot) { * Handles version-specific menu actions based on the IntelliJ IDEA version. * * @param remoteRobot Instance of the RemoteRobot to interact with the IntelliJ UI. - * @param menuAction1 The name of the menu item (e.g., "Run"). * @param menuAction2024_2 The submenu option for IntelliJ version 2024.2. * @param menuAction2024_3 The submenu option for IntelliJ version 2024.3. * @throws UnsupportedOperationException if the IntelliJ version is not supported. */ - public static void handleMenuBasedOnVersion(RemoteRobot remoteRobot, String menuAction1, String menuAction2024_2, String menuAction2024_3) { + public static String handleMenuBasedOnVersion(RemoteRobot remoteRobot, String menuAction2024_2, String menuAction2024_3) { // Using Remote robot's javascript API Retrieve the IntelliJ version String intellijVersion = remoteRobot.callJs("com.intellij.openapi.application.ApplicationInfo.getInstance().getFullVersion();"); @@ -2721,9 +2727,7 @@ public static void handleMenuBasedOnVersion(RemoteRobot remoteRobot, String menu throw new UnsupportedOperationException("Unsupported IntelliJ version: " + intellijVersion); } - // Perform the menu navigation ny locating project frame using the determined submenu option. - ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - projectFrame.clickOnMainMenuWithActions(remoteRobot, menuAction1, menuAction2); + return menuAction2; } } From 01c393c89dcfc6d0a52b5e88387e402f9af59b65 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:31:57 +0530 Subject: [PATCH 05/14] Updated memory size from 4g to 2g --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bd9efec3f..8436d3828 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ allprojects { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' options.fork = true - options.forkOptions.memoryMaximumSize = "4g" + options.forkOptions.memoryMaximumSize = "2g" } } From e9aac950cc521555aa1ebe2cd3733900d5207047 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:32:46 +0530 Subject: [PATCH 06/14] UI change run in 2024.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 331b93381..f262ffd4f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ javaVersion=17 # Target IntelliJ Community by default platformType=IC platformVersion=2024.1.7 -ideTargetVersion=2024.3 +ideTargetVersion=2024.2.5 # Example: platformBundledPlugins = com.intellij.java platformBundledPlugins=com.intellij.java, org.jetbrains.idea.maven, com.intellij.gradle, org.jetbrains.plugins.terminal, com.intellij.properties \ No newline at end of file From e75b3e850ae930902e9eda2c048a1fcb786c3d4e Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:33:09 +0530 Subject: [PATCH 07/14] Reverted back to 2024.3 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index f262ffd4f..331b93381 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ javaVersion=17 # Target IntelliJ Community by default platformType=IC platformVersion=2024.1.7 -ideTargetVersion=2024.2.5 +ideTargetVersion=2024.3 # Example: platformBundledPlugins = com.intellij.java platformBundledPlugins=com.intellij.java, org.jetbrains.idea.maven, com.intellij.gradle, org.jetbrains.plugins.terminal, com.intellij.properties \ No newline at end of file From accf954016aac5b66972055ccbb843e654d7093a Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:44:36 +0530 Subject: [PATCH 08/14] Removed unwanted logger --- .../java/io/openliberty/tools/intellij/it/UIBotTestUtils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index a5df3d129..e652aaefb 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -49,8 +49,6 @@ */ public class UIBotTestUtils { - private static final Logger log = LoggerFactory.getLogger(UIBotTestUtils.class); - /** * Print destination types. */ From f28c5d078a32f45e624c99239541c676d1d4065f Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:48:26 +0530 Subject: [PATCH 09/14] Removed unwanted import --- .../java/io/openliberty/tools/intellij/it/UIBotTestUtils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index e652aaefb..db99e1af4 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -22,8 +22,6 @@ import org.assertj.swing.core.MouseButton; import org.junit.Assert; import org.junit.jupiter.api.Assertions; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.awt.*; import java.awt.event.KeyEvent; From 1edeec4df21b0b0dfd06de4b8e2f5a47c24d4e45 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:07:33 +0530 Subject: [PATCH 10/14] Added os condition for closealltabs action --- .../tools/intellij/it/SingleModMPProjectTestCommon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index 1b221fa09..c794fea80 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -293,8 +293,8 @@ public static void cleanup() { * Close project. */ protected static void closeProjectView() { - UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); if (!remoteRobot.isMac()) { + UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3); UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3); } UIBotTestUtils.closeLibertyToolWindow(remoteRobot); From 15f366ba2bbfd6543e515bf666318404541e8ef3 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:19:56 +0530 Subject: [PATCH 11/14] Refactored few lines and added loop for list items --- .../tools/intellij/it/UIBotTestUtils.java | 42 ++++++++++++++----- .../it/fixtures/ProjectFrameFixture.java | 8 ++-- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index db99e1af4..8ee054170 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -1445,7 +1445,6 @@ public static void chooseQuickFix(RemoteRobot remoteRobot, String quickfixChoose * @param remoteRobot The RemoteRobot instance. */ public static void copyWindowContent(RemoteRobot remoteRobot) { - // Select the content. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); if (remoteRobot.isMac()) { projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); @@ -1474,7 +1473,7 @@ public static void copyWindowContent(RemoteRobot remoteRobot) { */ public static void clearWindowContent(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); - // Select the content. + if (remoteRobot.isMac()) { projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Delete"); @@ -1510,7 +1509,6 @@ public static void pasteOnActiveWindow(RemoteRobot remoteRobot, boolean homeCurs if (homeCursor) { goToLineAndColumn(remoteRobot, new Keyboard(remoteRobot), 1, 1); } - // Select the content. ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); if (remoteRobot.isMac()) { projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); @@ -2173,14 +2171,38 @@ public static Map getOpenedLibertyConfigDataAndCloseOnExit(Remot public static void selectConfigUsingToolbar(RemoteRobot remoteRobot, String cfgName) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); ComponentFixture cfgSelectBox = projectFrame.getRunConfigurationsComboBoxButton(); - cfgSelectBox.click(); - ComponentFixture cfgSelectPaneList = projectFrame.getMyList(); - List configs = cfgSelectPaneList.getData().getAll(); - for (RemoteText cfg : configs) { - if (cfg.getText().equals(cfgName)) { - cfg.click(); - break; + + boolean configFound = false; + int retryCount = 0; + int maxRetries = 5; + + while (!configFound && retryCount < maxRetries) { + cfgSelectBox.click(); + + ComponentFixture cfgSelectPaneList = projectFrame.getMyList(); + List configs = cfgSelectPaneList.getData().getAll(); + + if (configs != null && !configs.isEmpty()) { + for (RemoteText cfg : configs) { + if (cfg.getText().equals(cfgName)) { + cfg.click(); + configFound = true; + break; + } + } } + if (!configFound) { + retryCount++; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException("Thread interrupted while waiting for configuration list", e); + } + } + } + if (!configFound) { + throw new RuntimeException("Configuration '" + cfgName + "' not found after " + maxRetries + " attempts."); } } diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index e50f3b489..39e225e90 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -379,7 +379,7 @@ public void clickOnMainMenu(RemoteRobot remoteRobot) { * @param actions the sequence of actions to be performed in the menu hierarchy. */ public void clickOnMainMenuWithActions(RemoteRobot remoteRobot, String... actions) { - boolean actionPerformed = false; // Flag to indicate success + boolean actionPerformed = false; for (int attempt = 0; attempt < 5; attempt++) { try { @@ -404,14 +404,12 @@ public void clickOnMainMenuWithActions(RemoteRobot remoteRobot, String... action } TestUtils.sleepAndIgnoreException(3); - - // Find the next menu popup for further actions if (i < actions.length - 1) { currentMenuPopup = currentMenuPopup.get(0).findAll(ContainerFixture.class, byXpath("//div[@class='HeavyWeightWindow']")); } } - actionPerformed = true; // Mark as successful - break; // Exit loop if successful + actionPerformed = true; + break; } catch (WaitForConditionTimeoutException e) { System.err.println("Attempt " + (attempt + 1) + " failed: Timeout while trying to find or interact with menu items."); } catch (Exception e) { From 6461a80bfedad22320ca29c0af8b758b662594bd Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:37:14 +0530 Subject: [PATCH 12/14] Fixed text name as Terminal instead of Terminal: --- .../tools/intellij/it/fixtures/ProjectFrameFixture.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java index 39e225e90..7e3e8e442 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java +++ b/src/test/java/io/openliberty/tools/intellij/it/fixtures/ProjectFrameFixture.java @@ -223,7 +223,7 @@ public ComponentFixture getTree(String... xpathVars) { * Right-clicks on the terminal tab. */ public static void rightClickOnTerminalTab(ProjectFrameFixture projectFrame) { - String terminalLabelXPath = "//div[@class='TabPanel'][.//div[@class='BaseLabel']]//div[@text='Terminal:']"; + String terminalLabelXPath = "//div[@class='TabPanel'][.//div[@class='BaseLabel']]//div[@text='Terminal']"; ComponentFixture terminalLabel = projectFrame.getActionButton(terminalLabelXPath, "10"); terminalLabel.rightClick(); } From f94e1786bdd0280e59642c8fcb8e3f07f10e1263 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Fri, 6 Dec 2024 08:10:27 +0530 Subject: [PATCH 13/14] Added removed comments back --- .../tools/intellij/it/UIBotTestUtils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 8ee054170..6ef5e1cd6 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -1447,17 +1447,21 @@ public static void chooseQuickFix(RemoteRobot remoteRobot, String quickfixChoose public static void copyWindowContent(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); if (remoteRobot.isMac()) { + // Select the content. projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + // Copy the content. projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Copy"); } else { clickOnMainMenu(remoteRobot); + // Select the content. ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); editMenuEntry.moveMouse(); ComponentFixture slectAllEntry = projectFrame.getActionMenuItem("Select All"); slectAllEntry.click(); clickOnMainMenu(remoteRobot); + // Copy the content. ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); editMenuEntryNew.moveMouse(); ComponentFixture copyEntry = projectFrame.getActionMenuItem("Copy"); @@ -1475,16 +1479,20 @@ public static void clearWindowContent(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); if (remoteRobot.isMac()) { + // Select the content. projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + // Delete/Clear the content. projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Delete"); } else { clickOnMainMenu(remoteRobot); + // Select the content. ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); editMenuEntry.moveMouse(); ComponentFixture selectAllEntry = projectFrame.getActionMenuItem("Select All"); selectAllEntry.click(); clickOnMainMenu(remoteRobot); + // Delete/Clear the content. ComponentFixture editMenuEntryNew = projectFrame.getActionMenu("Edit", "10"); editMenuEntryNew.moveMouse(); ComponentFixture deleteEntry = projectFrame.getActionMenuItem("Delete"); @@ -1511,17 +1519,22 @@ public static void pasteOnActiveWindow(RemoteRobot remoteRobot, boolean homeCurs } ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30)); if (remoteRobot.isMac()) { + // Select the content. projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All"); + // Paste the content. projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Paste", "Paste"); + //Save projectFrame.clickOnMainMenuWithActions(remoteRobot, "File", "Save All"); } else { clickOnMainMenu(remoteRobot); + // Select the content. ComponentFixture editMenuEntry = projectFrame.getActionMenu("Edit", "10"); editMenuEntry.moveMouse(); ComponentFixture selectAllEntry = projectFrame.getActionMenuItem("Select All"); selectAllEntry.click(); clickOnMainMenu(remoteRobot); + // Paste the content. editMenuEntry = projectFrame.getActionMenu("Edit", "10"); editMenuEntry.moveMouse(); ComponentFixture pasteFixture = projectFrame.getChildActionMenu("Edit", "Paste"); @@ -1529,6 +1542,7 @@ public static void pasteOnActiveWindow(RemoteRobot remoteRobot, boolean homeCurs ComponentFixture pasteChildEntry = projectFrame.getChildActionMenuItem("Edit", "Paste"); pasteChildEntry.click(); clickOnMainMenu(remoteRobot); + //Save ComponentFixture fileMenuEntry = projectFrame.getActionMenu("File", "10"); fileMenuEntry.moveMouse(); ComponentFixture saveAllEntry = projectFrame.getActionMenuItem("Save All"); From f329224ad0e2c159a50451d31c9438828ccff349 Mon Sep 17 00:00:00 2001 From: Staicy Mathew <40750411+staicy123@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:55:04 +0530 Subject: [PATCH 14/14] Added comment for code review --- .../java/io/openliberty/tools/intellij/it/UIBotTestUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java index 6ef5e1cd6..23bf08fce 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java +++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java @@ -215,11 +215,13 @@ public static DialogFixture getOpenProjectLocationDialog(CommonContainerFixture */ public static void closeProjectFrame(RemoteRobot remoteRobot) { ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - // minimize windows os intellij ide to default state + if (remoteRobot.isMac()) { + // Click on File on the Menu bar. projectFrame.clickOnMainMenuWithActions(remoteRobot, "File", "Close Project"); } else { + // minimize windows os intellij ide to default state if (remoteRobot.isWin()) { minimizeWindow(remoteRobot); }