Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1127 mac UI test integration #1156

42 changes: 32 additions & 10 deletions src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -1510,7 +1509,6 @@ public static void pasteOnActiveWindow(RemoteRobot remoteRobot, boolean homeCurs
if (homeCursor) {
goToLineAndColumn(remoteRobot, new Keyboard(remoteRobot), 1, 1);
}
// Select the content.
staicy123 marked this conversation as resolved.
Show resolved Hide resolved
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30));
if (remoteRobot.isMac()) {
projectFrame.clickOnMainMenuWithActions(remoteRobot, "Edit", "Select All");
Expand Down Expand Up @@ -2173,14 +2171,38 @@ public static Map<String, String> 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<RemoteText> 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<RemoteText> 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.");
staicy123 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Loading