From 5f4009a73e12c320d5acdc44d9d110501e4d2415 Mon Sep 17 00:00:00 2001 From: Paul Gooderham Date: Tue, 21 Jan 2025 14:19:18 -0500 Subject: [PATCH] Handle situation when there is no terminal tab to close Signed-off-by: Paul Gooderham --- .../it/SingleModMPProjectTestCommon.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 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 c794fea80..4d650c997 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 IBM Corporation. + * Copyright (c) 2023, 2025 IBM Corporation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -13,6 +13,7 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.fixtures.ComponentFixture; import com.intellij.remoterobot.utils.Keyboard; +import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import io.openliberty.tools.intellij.it.fixtures.ProjectFrameFixture; import org.junit.jupiter.api.*; import org.junit.jupiter.api.condition.EnabledOnOs; @@ -1242,11 +1243,15 @@ public static void deleteDirectoryIfExists(String dirPath) { * Clean project. */ public void stopTerminal() { - Keyboard keyboard = new Keyboard(remoteRobot); - ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); - ComponentFixture terminal = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='JBTerminalPanel']"), Duration.ofSeconds(10)); - + ProjectFrameFixture projectFrame; + ComponentFixture terminal; + try { + projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10)); + terminal = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='JBTerminalPanel']"), Duration.ofSeconds(10)); + } catch (WaitForConditionTimeoutException w) { + return; // there is no terminal with a Liberty to stop + } terminal.rightClick(); ComponentFixture openFixtureNewTab = projectFrame.getActionMenuItem("New Tab"); openFixtureNewTab.click(new Point()); @@ -1268,7 +1273,6 @@ public void stopTerminal() { * Stop the Server. */ public void cleanTerminal() { - Keyboard keyboard = new Keyboard(remoteRobot); // Perform clean if (getBuildCategory() == BuildType.MAVEN_TYPE) {