1717import com .intellij .remoterobot .fixtures .ContainerFixture ;
1818import com .intellij .remoterobot .fixtures .DefaultXpath ;
1919import com .intellij .remoterobot .fixtures .FixtureName ;
20- import com .intellij .remoterobot .fixtures .HeavyWeightWindowFixture ;
2120import com .intellij .remoterobot .fixtures .JButtonFixture ;
22- import com .intellij .remoterobot .fixtures .JListFixture ;
2321import com .intellij .remoterobot .fixtures .JPopupMenuFixture ;
2422import com .intellij .remoterobot .fixtures .JTreeFixture ;
2523import com .intellij .remoterobot .utils .UtilsKt ;
@@ -91,14 +89,7 @@ public void openProject(String projectName) {
9189 * @param label label of the link to click on
9290 */
9391 public void clickOnLink (String label ) {
94- // Code for IntelliJ IDEA 2020.3 or newer
95- if (ideaVersionInt >= 20203 ) {
96- welcomeFrameLink (label ).click ();
97- }
98- // Code for IntelliJ IDEA 2020.2 or earlier
99- else {
100- actionLink (label ).click ();
101- }
92+ welcomeFrameLink (label ).click ();
10293 }
10394
10495 /**
@@ -134,11 +125,11 @@ public void clearWorkspace() {
134125 public void clearExceptions () {
135126 try {
136127 ideErrorsIcon ().click ();
137- find (IdeFatalErrorsDialog .class , Duration .ofSeconds (10 )).clearAll ();
128+ find (IdeFatalErrorsDialog .class , Duration .ofSeconds (5 )).clearAll ();
138129 } catch (WaitForConditionTimeoutException e ) {
139130 LOGGER .log (Level .INFO , "No fatal errors dialog found to clear." );
140131 try {
141- find (IdeFatalErrorsDialog .class , Duration .ofSeconds (10 )).clearAll ();
132+ find (IdeFatalErrorsDialog .class , Duration .ofSeconds (5 )).clearAll ();
142133 } catch (Exception e2 ) {
143134 LOGGER .log (Level .INFO , "Second attempt to clear fatal errors dialog also failed." );
144135 }
@@ -149,22 +140,18 @@ public void clearExceptions() {
149140 * Open the 'Preferences' dialog
150141 */
151142 public void openSettingsDialog () {
152- if (ideaVersionInt <= 20202 ) {
153- clickOnLink ("Configure" );
154- HeavyWeightWindowFixture heavyWeightWindowFixture = find (HeavyWeightWindowFixture .class , Duration .ofSeconds (5 ));
155- heavyWeightWindowFixture .findText ("Preferences" ).click ();
156- } else if (ideaVersionInt <= 20212 ) {
157- JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (XPathDefinitions .JBLIST ));
158- jListFixture .clickItem ("Customize" , false );
159- remoteRobot .find (ContainerFixture .class , byXpath (XPathDefinitions .DIALOG_PANEL )).findText ("All settings" + '\u2026' ).click ();
160- } else {
161- JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions .TREE ));
162- jTreeFixture .findText ("Customize" ).click ();
163- if (remoteRobot .isMac ()) {
164- resizeWelcomeWindow ();
165- }
166- remoteRobot .find (ContainerFixture .class , byXpath (XPathDefinitions .DIALOG_PANEL )).findText ("All settings" + '\u2026' ).click ();
143+ JTreeFixture jTreeFixture ;
144+ try {
145+ jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions .TREE ));
146+ } catch (WaitForConditionTimeoutException e ) {
147+ // workaround for 2022.3
148+ jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions .TREE_FOR_20223 ));
149+ }
150+ jTreeFixture .findText ("Customize" ).click ();
151+ if (remoteRobot .isMac ()) {
152+ resizeWelcomeWindow ();
167153 }
154+ remoteRobot .find (ContainerFixture .class , byXpath (XPathDefinitions .DIALOG_PANEL )).findText ("All settings" + '\u2026' ).click ();
168155 }
169156
170157 /**
@@ -204,25 +191,10 @@ private void resizeWelcomeWindow() {
204191 * @return fixture for the 'Tip Of the Day' dialog
205192 */
206193 public TipDialog openTipDialog () {
207- if (ideaVersionInt >= 20211 ) {
208- FlatWelcomeFrame flatWelcomeFrame = remoteRobot .find (FlatWelcomeFrame .class , Duration .ofSeconds (2 ));
209- if (ideaVersionInt >= 20223 ) { // COMMUNITY_V_2022_3 and higher version have different labels for Learn button
210- flatWelcomeFrame .findText (ButtonLabels .LEARN_LABEL ).click ();
211- } else {
212- flatWelcomeFrame .findText (ButtonLabels .LEARN_INTELLIJ_IDEA_LABEL ).click ();
213- }
214- SharedSteps .waitForComponentByXpath (remoteRobot , 2 , 200 , byXpath (XPathDefinitions .TIP_DIALOG_2 ));
215- flatWelcomeFrame .findText (TIP_OF_THE_DAY ).click ();
216- } else if (ideaVersionInt <= 20202 ) {
217- clickOnLink ("Get Help" );
218- HeavyWeightWindowFixture heavyWeightWindowFixture = find (HeavyWeightWindowFixture .class , Duration .ofSeconds (5 ));
219- heavyWeightWindowFixture .findText (TIP_OF_THE_DAY ).click ();
220- } else if (ideaVersionInt == 20203 ) { // IJ 2020.3
221- actionLink ("Help" ).click ();
222- HeavyWeightWindowFixture heavyWeightWindowFixture = find (HeavyWeightWindowFixture .class , Duration .ofSeconds (5 ));
223- heavyWeightWindowFixture .findText (TIP_OF_THE_DAY ).click ();
224- }
225-
194+ FlatWelcomeFrame flatWelcomeFrame = remoteRobot .find (FlatWelcomeFrame .class , Duration .ofSeconds (2 ));
195+ flatWelcomeFrame .findText (ButtonLabels .LEARN_LABEL ).click ();
196+ SharedSteps .waitForComponentByXpath (remoteRobot , 2 , 200 , byXpath (XPathDefinitions .TIP_DIALOG_2 ));
197+ flatWelcomeFrame .findText (TIP_OF_THE_DAY ).click ();
226198 return remoteRobot .find (TipDialog .class , Duration .ofSeconds (10 ));
227199 }
228200
@@ -239,45 +211,26 @@ public void disableNotifications() {
239211 switchToProjectsPage ();
240212 }
241213
242- /**
243- * Prevent the 'Tip of the Day' dialog from opening after project import
244- */
245- public void preventTipDialogFromOpening () {
246- TipDialog tipDialog = openTipDialog ();
247- tipDialog .dontShowTipsCheckBox ().setValue (true );
248- tipDialog .close ();
249- switchToProjectsPage ();
250- }
251-
252214 /**
253215 * Switch to the 'Projects' page of flat welcome frame
254216 */
255217 public void switchToProjectsPage () {
256- if ( ideaVersionInt >= 20213 ) {
257- JTreeFixture jTreeFixture = remoteRobot . find ( JTreeFixture . class , byXpath ( XPathDefinitions . TREE ));
258- jTreeFixture . findText ( PROJECTS_BUTTON ). click ( );
259- } else if ( ideaVersionInt >= 20203 ) {
260- JListFixture jListFixture = remoteRobot . find ( JListFixture . class , byXpath ( XPathDefinitions . JBLIST ));
261- jListFixture . clickItem ( PROJECTS_BUTTON , false );
218+ JTreeFixture jTreeFixture ;
219+ try {
220+ jTreeFixture = remoteRobot . find ( JTreeFixture . class , byXpath ( XPathDefinitions . TREE ) );
221+ } catch ( WaitForConditionTimeoutException e ) {
222+ // workaround for 2022.3
223+ jTreeFixture = remoteRobot . find ( JTreeFixture . class , byXpath ( XPathDefinitions . TREE_FOR_20223 ) );
262224 }
225+ jTreeFixture .findText (PROJECTS_BUTTON ).click ();
263226 }
264227
265228 private int projectsCount () {
266- if (ideaVersionInt >= 20222 ) {
267- try {
268- JTreeFixture projects = remoteRobot .findAll (JTreeFixture .class , byXpath (XPathDefinitions .RECENT_PROJECT_PANEL_NEW_2 )).get (0 );
269- return projects .findAllText ().size () / 2 ;
270- } catch (IndexOutOfBoundsException e ) {
271- return 0 ;
272- }
273- } else {
274- try {
275- ContainerFixture projectWrapper = find (ContainerFixture .class , byXpath (XPathDefinitions .RECENT_PROJECT_PANEL_NEW ));
276- JListFixture projectList = projectWrapper .find (JListFixture .class , byXpath (XPathDefinitions .MY_LIST ));
277- return projectList .collectItems ().size ();
278- } catch (WaitForConditionTimeoutException e ) {
279- return 0 ;
280- }
229+ try {
230+ JTreeFixture projects = remoteRobot .findAll (JTreeFixture .class , byXpath (XPathDefinitions .RECENT_PROJECT_PANEL_NEW_2 )).get (0 );
231+ return projects .findAllText ().size () / 2 ;
232+ } catch (IndexOutOfBoundsException e ) {
233+ return 0 ;
281234 }
282235 }
283236
@@ -293,16 +246,11 @@ private JButtonFixture welcomeFrameLink(String label) {
293246 }
294247
295248 private ComponentFixture ideErrorsIcon () {
296- return find (ComponentFixture .class , byXpath (XPathDefinitions .IDE_ERROR_ICON ), Duration .ofSeconds (10 ));
249+ return find (ComponentFixture .class , byXpath (XPathDefinitions .IDE_ERROR_ICON ), Duration .ofSeconds (5 ));
297250 }
298251
299252 private void removeTopProjectFromRecentProjects () {
300- ComponentFixture recentProjects ;
301- if (ideaVersionInt >= 20222 ) {
302- recentProjects = remoteRobot .findAll (JTreeFixture .class , byXpath (XPathDefinitions .RECENT_PROJECT_PANEL_NEW_2 )).get (0 );
303- } else {
304- recentProjects = jLists (byXpath (XPathDefinitions .RECENT_PROJECTS )).get (0 );
305- }
253+ ComponentFixture recentProjects = remoteRobot .findAll (JTreeFixture .class , byXpath (XPathDefinitions .RECENT_PROJECT_PANEL_NEW_2 )).get (0 );
306254
307255 // Clicks on X on first recent project to remove it from the recent projects list (visible only when hovered over with cursor)
308256 recentProjects .runJs ("const horizontal_offset = component.getWidth()-22;\n " +
@@ -311,16 +259,12 @@ private void removeTopProjectFromRecentProjects() {
311259 if (ideaVersionInt >= 20231 ) {
312260 ComponentFixture removeDialog = remoteRobot .find (ComponentFixture .class , byXpath (XPathDefinitions .MY_DIALOG ), Duration .ofSeconds (10 ));
313261 removeDialog .findText (ButtonLabels .REMOVE_FROM_LIST_LABEL ).click ();
314- } else if ( ideaVersionInt >= 20203 ) { // Code for IntelliJ Idea 2020.3 or newer
262+ } else {
315263 List <JPopupMenuFixture > jPopupMenuFixtures = jPopupMenus (JPopupMenuFixture .Companion .byType ());
316264 if (!jPopupMenuFixtures .isEmpty ()) {
317265 JPopupMenuFixture contextMenu = jPopupMenuFixtures .get (0 );
318- if (ideaVersionInt >= 20222 ) {
319- contextMenu .select ("Remove from Recent Projects" + '\u2026' );
320- button (byXpath (XPathDefinitions .REMOVE_PROJECT_BUTTON )).click ();
321- } else {
322- contextMenu .select ("Remove from Recent Projects" );
323- }
266+ contextMenu .select ("Remove from Recent Projects" + '\u2026' );
267+ button (byXpath (XPathDefinitions .REMOVE_PROJECT_BUTTON )).click ();
324268 }
325269 }
326270 }
0 commit comments