diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java index 68c46405..58baf2cf 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java @@ -96,19 +96,8 @@ public void clickOnLink(String label) { * Clear the workspace by deleting the content of the IdeaProjects folder and clearing all the projects' links in the 'Welcome to IntelliJ IDEA' dialog */ public void clearWorkspace() { - List jListFixtures = jLists(byXpath(XPathDefinitions.RECENT_PROJECTS)); for (int i = 0; i < projectsCount(); i++) { - JListFixture recentProjectsList = jListFixtures.get(0); - recentProjectsList.runJs("const horizontal_offset = component.getWidth()-22;\n" + - "robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);"); - // Code for IntelliJ Idea 2020.3 or newer - if (ideaVersion >= 20203) { - List jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType()); - if (!jPopupMenuFixtures.isEmpty()) { - JPopupMenuFixture contextMenu = jPopupMenuFixtures.get(0); - contextMenu.select("Remove from Recent Projects"); - } - } + removeTopProjectFromRecentProjects(); } try { @@ -227,18 +216,27 @@ public void switchToProjectsPage() { } private int projectsCount() { - try { - ContainerFixture projectWrapper = find(ContainerFixture.class, byXpath(XPathDefinitions.NEW_RECENT_PROJECT_PANEL)); - JListFixture projectList = projectWrapper.find(JListFixture.class, byXpath(XPathDefinitions.MY_LIST)); - return projectList.collectItems().size(); - } catch (WaitForConditionTimeoutException e) { - return 0; + if (ideaVersion >= 20222) { + try { + JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); + return projects.findAllText().size() / 2; + } catch (IndexOutOfBoundsException e) { + return 0; + } + } else { + try { + ContainerFixture projectWrapper = find(ContainerFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW)); + JListFixture projectList = projectWrapper.find(JListFixture.class, byXpath(XPathDefinitions.MY_LIST)); + return projectList.collectItems().size(); + } catch (WaitForConditionTimeoutException e) { + return 0; + } } } // Works for IntelliJ Idea 2020.3+ private JButtonFixture welcomeFrameLink(String label) { - if (UtilsKt.hasAnyComponent(this, byXpath(XPathDefinitions.NEW_RECENT_PROJECT_PANEL))) { + if (UtilsKt.hasAnyComponent(this, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW))) { return button(byXpath(XPathDefinitions.jBOptionButton(label)), Duration.ofSeconds(2)); } return button(byXpath(XPathDefinitions.nonOpaquePanel(label)), Duration.ofSeconds(2)); @@ -247,4 +245,30 @@ private JButtonFixture welcomeFrameLink(String label) { private ComponentFixture ideErrorsIcon() { return find(ComponentFixture.class, byXpath(XPathDefinitions.IDE_ERROR_ICON), Duration.ofSeconds(10)); } + + private void removeTopProjectFromRecentProjects() { + ComponentFixture recentProjects; + if (ideaVersion >= 20222) { + recentProjects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); + } else { + recentProjects = jLists(byXpath(XPathDefinitions.RECENT_PROJECTS)).get(0); + } + + recentProjects.runJs("const horizontal_offset = component.getWidth()-22;\n" + + "robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);"); + + // Code for IntelliJ Idea 2020.3 or newer + if (ideaVersion >= 20203) { + List jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType()); + if (!jPopupMenuFixtures.isEmpty()) { + JPopupMenuFixture contextMenu = jPopupMenuFixtures.get(0); + if (ideaVersion >= 20222) { + contextMenu.select("Remove from Recent Projects" + '\u2026'); + button(byXpath(XPathDefinitions.REMOVE_PROJECT_BUTTON)).click(); + } else { + contextMenu.select("Remove from Recent Projects"); + } + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java index a4f1e322..bdef5398 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java @@ -46,7 +46,7 @@ protected AbstractNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull */ public String getProjectName() { if (UITestRunner.getIdeaVersionInt() >= 20221) { - return textFields(byXpath("//div[@class='JBTextField']")).get(0).getText(); + return textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).getText(); } else { return textFields(JTextFieldFixture.Companion.byType()).get(0).getText(); } @@ -59,7 +59,7 @@ public String getProjectName() { */ public void setProjectName(String projectName) { if (UITestRunner.getIdeaVersionInt() >= 20221) { - textFields(byXpath("//div[@class='JBTextField']")).get(0).setText(projectName); + textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).setText(projectName); } else { textFields(JTextFieldFixture.Companion.byType()).get(0).setText(projectName); } @@ -72,7 +72,7 @@ public void setProjectName(String projectName) { */ public String getProjectLocation() { if (UITestRunner.getIdeaVersionInt() >= 20221) { - return find(JTextFieldFixture.class, byXpath("//div[@class='ExtendableTextField']")).getText(); + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).getText(); } else { return textFields(JTextFieldFixture.Companion.byType()).get(1).getText(); } @@ -85,7 +85,7 @@ public String getProjectLocation() { */ public void setProjectLocation(String projectLocation) { if (UITestRunner.getIdeaVersionInt() >= 20221) { - find(JTextFieldFixture.class, byXpath("//div[@class='ExtendableTextField']")).setText(projectLocation); + find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD )).setText(projectLocation); } else { textFields(JTextFieldFixture.Companion.byType()).get(1).setText(projectLocation); } @@ -96,7 +96,11 @@ public void setProjectLocation(String projectLocation) { */ public void openAdvanceSettings() { if (!isAdvancedSettingsOpened()) { - find(ComponentFixture.class, byXpath("//div[@class='CollapsibleTitledSeparator']")).click(); + if (UITestRunner.getIdeaVersionInt() >= 20222) { + find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click(); + } else { + find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR)).click(); + } } } @@ -105,15 +109,26 @@ public void openAdvanceSettings() { */ public void closeAdvanceSettings() { if (isAdvancedSettingsOpened()) { - find(ComponentFixture.class, byXpath("//div[@class='CollapsibleTitledSeparator']")).click(); + if (UITestRunner.getIdeaVersionInt() >= 20222) { + find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click(); + } else { + find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR)).click(); + } } } private boolean isAdvancedSettingsOpened() { - List ss = findAll(ComponentFixture.class, byXpath("//div[@class='CollapsibleTitledSeparator']/../*")); - for (int i = 0; i < ss.size(); i++) { - if (listOfRemoteTextToString(ss.get(i).findAllText()).contains("Advanced Settings")) { - return i != ss.size() - 1; + List cf; + + if (UITestRunner.getIdeaVersionInt() >= 20222) { + cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS)); + } else { + cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_SIBLINGS)); + } + + for (int i = 0; i < cf.size(); i++) { + if (listOfRemoteTextToString(cf.get(i).findAllText()).contains("Advanced Settings")) { + return i != cf.size() - 1; } } throw new UITestException("Wizard does not contain 'Advanced Settings' section."); diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java index 114c4248..4a08c8a3 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java @@ -71,7 +71,7 @@ public void closeMoreSettings() { */ public String getModuleName() { if (UITestRunner.getIdeaVersionInt() >= 20221) { - return find(JTextFieldFixture.class, byXpath("//div[@accessiblename='Module name:' and @accessiblename.key='label.project.wizard.new.project.module.name' and @class='JBTextField']")).getText(); + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).getText(); } else { return textField("Module name:", true).getText(); } @@ -84,7 +84,7 @@ public String getModuleName() { */ public void setModuleName(String moduleName) { if (UITestRunner.getIdeaVersionInt() >= 20221) { - find(JTextFieldFixture.class, byXpath("//div[@accessiblename='Module name:' and @accessiblename.key='label.project.wizard.new.project.module.name' and @class='JBTextField']")).setText(moduleName); + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).setText(moduleName); } else { textField("Module name:", true).setText(moduleName); } @@ -97,7 +97,7 @@ public void setModuleName(String moduleName) { */ public String getContentRoot() { if (UITestRunner.getIdeaVersionInt() >= 20221) { - return find(JTextFieldFixture.class, byXpath("//div[@accessiblename='Content root:' and @accessiblename.key='label.project.wizard.new.project.content.root' and @class='ExtendableTextField']")).getText(); + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).getText(); } else { return textField("Content root:", true).getText(); } @@ -110,7 +110,7 @@ public String getContentRoot() { */ public void setContentRoot(String contentRoot) { if (UITestRunner.getIdeaVersionInt() >= 20221) { - find(JTextFieldFixture.class, byXpath("//div[@accessiblename='Content root:' and @accessiblename.key='label.project.wizard.new.project.content.root' and @class='ExtendableTextField']")).setText(contentRoot); + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).setText(contentRoot); } else { textField("Content root:", true).setText(contentRoot); } @@ -123,7 +123,7 @@ public void setContentRoot(String contentRoot) { */ public String getModuleFileLocation() { if (UITestRunner.getIdeaVersionInt() >= 20221) { - return find(JTextFieldFixture.class, byXpath("//div[@accessiblename='Module file location:' and @accessiblename.key='label.project.wizard.new.project.module.file.location' and @class='ExtendableTextField']")).getText(); + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).getText(); } else { return textField("Module file location:", true).getText(); } @@ -136,7 +136,7 @@ public String getModuleFileLocation() { */ public void setModuleFileLocation(String moduleFileLocation) { if (UITestRunner.getIdeaVersionInt() >= 20221) { - find(JTextFieldFixture.class, byXpath("//div[@accessiblename='Module file location:' and @accessiblename.key='label.project.wizard.new.project.module.file.location' and @class='ExtendableTextField']")).setText(moduleFileLocation); + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).setText(moduleFileLocation); } else { textField("Module file location:", true).setText(moduleFileLocation); } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java index a073399a..07bdf922 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java @@ -67,7 +67,7 @@ public void selectNewProjectType(String projectType) { */ @Override public void setProjectName(String projectName) { - find(JTextFieldFixture.class, byXpath("//div[@class='JBTextField']")).setText(projectName); + find(JTextFieldFixture.class, byXpath(XPathDefinitions.JBTEXT_FIELD)).setText(projectName); } /** @@ -76,7 +76,7 @@ public void setProjectName(String projectName) { * @param language project language */ public void setLanguage(String language) { - findAll(JLabelFixture.class, byXpath("//div[@class='SegmentedButtonComponent'][.//div[contains(@action.key, 'language.groovy')]]")).get(0).findText(language).click(); + findAll(JLabelFixture.class, byXpath(XPathDefinitions.SET_LANGUAGE)).get(0).findText(language).click(); } /** @@ -85,7 +85,7 @@ public void setLanguage(String language) { * @param buildSystem build system type */ public void setBuildSystem(String buildSystem) { - find(JLabelFixture.class, byXpath("//div[@class='SegmentedButtonComponent'][.//div[@action.key='buildsystem.type.intellij']]")).findText(buildSystem).click(); + find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM)).findText(buildSystem).click(); } /** diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java index dbff7da7..9dc16898 100755 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java @@ -75,8 +75,10 @@ private JButtonFixture mainMenuItem(String label) { CommonContainerFixture cf; if (remoteRobot.isLinux()) { cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.LINUX_MAIN_MENU), Duration.ofSeconds(10)); + } else if (remoteRobot.isWin() && ideaVersion.toInt() >= 20222) { + cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2022_2_AND_NEWER), Duration.ofSeconds(10)); } else if (remoteRobot.isWin() && ideaVersion.toInt() >= 20203) { - cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_3_AND_NEWER), Duration.ofSeconds(10)); + cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_3_TO_2022_1), Duration.ofSeconds(10)); } else { cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_2_AND_OLDER), Duration.ofSeconds(10)); } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java index 94fa3a81..d496950f 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java @@ -20,6 +20,7 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.GradleBuildToolPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.MavenBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; +import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; import org.jetbrains.annotations.NotNull; import java.time.Duration; @@ -98,12 +99,12 @@ public void closeGradleBuildToolPane() { public JButtonFixture stripeButton(String label, boolean isPaneOpened) { if (isPaneOpened) { if (label.equals(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL) || label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL)) { - return button(byXpath("//div[@disabledicon='toolWindow" + label + ".svg']"), Duration.ofSeconds(2)); + return button(byXpath(XPathDefinitions.toolWindowSvg(label)), Duration.ofSeconds(2)); } else if (label.equals(ButtonLabels.PROJECT_STRIPE_BUTTON_LABEL)) { - return button(byXpath("//div[@tooltiptext='Project']"), Duration.ofSeconds(2)); + return button(byXpath(XPathDefinitions.TOOLTIP_TEXT_PROJECT), Duration.ofSeconds(2)); } } - return button(byXpath("//div[@text='" + label + "']"), Duration.ofSeconds(2)); + return button(byXpath(XPathDefinitions.label(label)), Duration.ofSeconds(2)); } protected T togglePane(String label, Class fixtureClass, boolean openPane) { diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java index 0cd21f37..1d19d51d 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java @@ -25,7 +25,8 @@ public class XPathDefinitions { public static final String MAVEN_TOOL_WINDOW = "//div[@accessiblename='Maven Tool Window']"; public static final String GRADLE_TOOL_WINDOW = "//div[@accessiblename='Gradle Tool Window']"; public static final String LINUX_MAIN_MENU = "//div[@class='LinuxIdeMenuBar']"; - public static final String WINDOWS_MAIN_MENU_2020_3_AND_NEWER = "//div[@class='MenuFrameHeader']"; + public static final String WINDOWS_MAIN_MENU_2022_2_AND_NEWER = "//div[@class='IdeMenuBar']"; + public static final String WINDOWS_MAIN_MENU_2020_3_TO_2022_1 = "//div[@class='MenuFrameHeader']"; public static final String WINDOWS_MAIN_MENU_2020_2_AND_OLDER = "//div[@class='CustomHeaderMenuBar']"; public static final String IDE_STATUS_BAR = "//div[@class='IdeStatusBarImpl']"; public static final String INLINE_PROGRESS_PANEL = "//div[@class='InlineProgressPanel']"; @@ -35,12 +36,12 @@ public class XPathDefinitions { public static final String DIALOG_ROOT_PANE = "//div[@class='DialogRootPane']"; public static final String SEARCH_EVERYWHERE_POPUP = "//div[@accessiblename='Search everywhere' and @class='SearchEverywhereUI']"; public static final String IDE_FATAL_ERRORS_DIALOG = "//div[@accessiblename='IDE Fatal Errors' and @class='MyDialog']"; - public static final String IDE_INTERNAL_ERRORS_DIALOG = "//div[@class='DialogRootPane']"; public static final String PROJECT_STRUCTURE_DIALOG = "//div[@accessiblename='Project Structure' and @class='MyDialog']"; public static final String TIP_DIALOG = "//div[@accessiblename='Tip of the Day' and @class='MyDialog']"; public static final String TIP_DIALOG_2 = "//div[@text='Tip of the Day']"; public static final String RECENT_PROJECTS = "//div[@accessiblename='Recent Projects']"; - public static final String NEW_RECENT_PROJECT_PANEL = "//div[@class='NewRecentProjectPanel']"; + public static final String RECENT_PROJECT_PANEL_NEW = "//div[@class='NewRecentProjectPanel']"; + public static final String RECENT_PROJECT_PANEL_NEW_2 = "//div[@class='JBViewport']/*"; public static final String IDE_ERROR_ICON = "//div[@class='IdeErrorsIcon']"; public static final String BUILD_VIEW_EDITOR = "//div[@accessiblename='Editor']"; public static final String JCOMBOBOX = "//div[@class='JComboBox']"; @@ -68,6 +69,18 @@ public class XPathDefinitions { public static final String BREAD_CRUMBS = "//div[@class='Breadcrumbs']"; public static final String EMPTY_PROJECT = "//div[@visible_text='Empty Project']"; public static final String SINGLE_HEIGHT_LABEL = "//div[@class='SingleHeightLabel']"; + public static final String COLLAPSIBLE_TITLED_SEPARATOR = "//div[@class='CollapsibleTitledSeparator']"; + public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW = "//div[@class='CollapsibleTitledSeparatorImpl']"; + public static final String COLLAPSIBLE_TITLED_SEPARATOR_SIBLINGS = COLLAPSIBLE_TITLED_SEPARATOR + "/../*"; + public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS = COLLAPSIBLE_TITLED_SEPARATOR_NEW + "/../*"; + public static final String EXTENDABLE_TEXT_FIELD = "//div[@class='ExtendableTextField']"; + public static final String JBTEXT_FIELD = "//div[@class='JBTextField']"; + public static final String REMOVE_PROJECT_BUTTON = "//div[contains(@text.key, 'button.remove')]"; + public static final String SET_LANGUAGE = "//div[@class='SegmentedButtonComponent'][.//div[contains(@action.key, 'language.groovy')]]"; + public static final String SET_BUILD_SYSTEM = "//div[@class='SegmentedButtonComponent'][.//div[@action.key='buildsystem.type.intellij']]"; + public static final String GET_SET_MODULE_NAME = "//div[@accessiblename='Module name:' and @accessiblename.key='label.project.wizard.new.project.module.name' and @class='JBTextField']"; + public static final String GET_SET_CONTENT_ROOT = "//div[@accessiblename='Content root:' and @accessiblename.key='label.project.wizard.new.project.content.root' and @class='ExtendableTextField']"; + public static final String GET_SET_MODULE_FILE_LOCATION = "//div[@accessiblename='Module file location:' and @accessiblename.key='label.project.wizard.new.project.module.file.location' and @class='ExtendableTextField']"; private XPathDefinitions() { throw new UITestException("Utility class with static methods."); diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/internalerror/IdeInternalErrorUtils.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/internalerror/IdeInternalErrorUtils.java index 5856cae8..c5d65f90 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/internalerror/IdeInternalErrorUtils.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/internalerror/IdeInternalErrorUtils.java @@ -40,7 +40,7 @@ private IdeInternalErrorUtils() {} public static void clearWindowsErrorsIfTheyAppear(RemoteRobot remoteRobot) { if (remoteRobot.isWin()) { try { - remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.IDE_INTERNAL_ERRORS_DIALOG), Duration.ofSeconds(10)).button(ButtonLabels.CLEAR_ALL_LABEL).click(); + remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.DIALOG_ROOT_PANE), Duration.ofSeconds(10)).button(ButtonLabels.CLEAR_ALL_LABEL).click(); } catch (WaitForConditionTimeoutException e) { LOGGER.log(Level.INFO, e.getMessage(), e); } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java index 19dcd793..f4298e4f 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java @@ -22,6 +22,7 @@ public enum IntelliJVersion { COMMUNITY_V_2021_2("IC-2021.2"), COMMUNITY_V_2021_3("IC-2021.3"), COMMUNITY_V_2022_1("IC-2022.1"), + COMMUNITY_V_2022_2("IC-2022.2"), ULTIMATE_V_2020_2("IU-2020.2"), ULTIMATE_V_2020_3("IU-2020.3"), ULTIMATE_V_2021_1("IU-2021.1"), diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java index fd79f1b6..32c4f204 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java @@ -31,7 +31,7 @@ @ExtendWith(ScreenshotAfterTestFailExtension.class) public class LibraryTestBase { protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName()); - private static final IntelliJVersion ideaVersion = IntelliJVersion.COMMUNITY_V_2022_1; + private static final IntelliJVersion ideaVersion = IntelliJVersion.COMMUNITY_V_2022_2; protected static RemoteRobot remoteRobot; protected static int ideaVersionInt = ideaVersion.toInt(); private static boolean intelliJHasStarted = false; diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java index 2fbf5550..da24b380 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java @@ -11,6 +11,7 @@ package com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs; import com.intellij.remoterobot.fixtures.JListFixture; +import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.LibraryTestBase; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; @@ -82,13 +83,22 @@ private int getNumberOfProjectsOnDisk() { } private int getNumberOfProjectLinks() { - try { - flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); - JListFixture recentProjectsList = flatWelcomeFrame.find(JListFixture.class, byXpath(XPathDefinitions.RECENT_PROJECTS), Duration.ofSeconds(10)); - return recentProjectsList.findAllText().size() / 2; // 2 items per 1 project link (project path and project name) - } catch (WaitForConditionTimeoutException e) { - // the list with accessible name 'Recent Projects' is not available -> 0 links in the 'Welcome to IntelliJ IDEA' dialog - return 0; + if (ideaVersionInt >= 20222) { + try { + JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); + return projects.findAllText().size() / 2; + } catch (IndexOutOfBoundsException e) { + return 0; + } + } else { + try { + flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); + JListFixture recentProjectsList = flatWelcomeFrame.find(JListFixture.class, byXpath(XPathDefinitions.RECENT_PROJECTS), Duration.ofSeconds(10)); + return recentProjectsList.findAllText().size() / 2; // 2 items per 1 project link (project path and project name) + } catch (WaitForConditionTimeoutException e) { + // the list with accessible name 'Recent Projects' is not available -> 0 links in the 'Welcome to IntelliJ IDEA' dialog + return 0; + } } } } \ No newline at end of file