From 9e335a9d6b4b9fab7bb94357de564706ef292657 Mon Sep 17 00:00:00 2001 From: Oleksii Korniienko Date: Thu, 9 May 2024 15:11:08 +0200 Subject: [PATCH] Reworked/refactored CreateResourceByEditTest Signed-off-by: Oleksii Korniienko --- .../tests/CreateResourceByEditTest.java | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/it/java/org/jboss/tools/intellij/kubernetes/tests/CreateResourceByEditTest.java b/src/it/java/org/jboss/tools/intellij/kubernetes/tests/CreateResourceByEditTest.java index 630fd4c70..8e2287587 100644 --- a/src/it/java/org/jboss/tools/intellij/kubernetes/tests/CreateResourceByEditTest.java +++ b/src/it/java/org/jboss/tools/intellij/kubernetes/tests/CreateResourceByEditTest.java @@ -20,12 +20,13 @@ import org.jboss.tools.intellij.kubernetes.fixtures.menus.ActionToolbarMenu; import org.jboss.tools.intellij.kubernetes.fixtures.menus.RightClickMenu; -import java.awt.event.KeyEvent; import java.time.Duration; import java.util.List; + import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author olkornii@redhat.com @@ -70,36 +71,24 @@ public static void deleteResource(RemoteRobot robot, ComponentFixture kubernetes } private static RemoteText findResourceNamePosition(RemoteRobot robot, EditorsSplittersFixture editorSplitter, Keyboard myKeyboard){ - myKeyboard.hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_F); - robot.find(ComponentFixture.class, byXpath("//div[@class='SearchTextArea']")).click(); - myKeyboard.enterText(" name:"); - + scrollToVisible(" name:", robot); ComponentFixture textFixture = editorSplitter.getEditorTextFixture(); List remoteText = textFixture.findAllText(); - System.out.println("=================================================================================="); - - for (RemoteText actual_remote_text : remoteText) { - System.out.println(actual_remote_text.getText()); - } - - System.out.println("=================================================================================="); - int nameId = 0; + boolean nameFound = false; for (RemoteText actual_remote_text : remoteText){ - System.out.println(actual_remote_text.getText()); if ("name".equals(actual_remote_text.getText())){ + nameFound = true; break; } nameId++; } - System.out.println("=================================================================================="); - - RemoteText namePlace = remoteText.get(nameId+3); // +1 because we need the next one, +1 because between every 2 real elements is space, +1 because here is the ":" + assertTrue(nameFound, "Resource name not found."); - return namePlace; + return remoteText.get(nameId+3); // +1 because we need the next one, +1 because between every 2 real elements is space, +1 because here is the ":" } private static boolean acceptDeleteDialog(RemoteRobot robot){