17
17
import com .intellij .remoterobot .fixtures .ContainerFixture ;
18
18
import com .intellij .remoterobot .fixtures .DefaultXpath ;
19
19
import com .intellij .remoterobot .fixtures .FixtureName ;
20
- import com .intellij .remoterobot .fixtures .HeavyWeightWindowFixture ;
21
20
import com .intellij .remoterobot .fixtures .JButtonFixture ;
22
- import com .intellij .remoterobot .fixtures .JListFixture ;
23
21
import com .intellij .remoterobot .fixtures .JPopupMenuFixture ;
24
22
import com .intellij .remoterobot .fixtures .JTreeFixture ;
25
23
import com .intellij .remoterobot .utils .UtilsKt ;
@@ -91,14 +89,7 @@ public void openProject(String projectName) {
91
89
* @param label label of the link to click on
92
90
*/
93
91
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 ();
102
93
}
103
94
104
95
/**
@@ -134,11 +125,11 @@ public void clearWorkspace() {
134
125
public void clearExceptions () {
135
126
try {
136
127
ideErrorsIcon ().click ();
137
- find (IdeFatalErrorsDialog .class , Duration .ofSeconds (10 )).clearAll ();
128
+ find (IdeFatalErrorsDialog .class , Duration .ofSeconds (5 )).clearAll ();
138
129
} catch (WaitForConditionTimeoutException e ) {
139
130
LOGGER .log (Level .INFO , "No fatal errors dialog found to clear." );
140
131
try {
141
- find (IdeFatalErrorsDialog .class , Duration .ofSeconds (10 )).clearAll ();
132
+ find (IdeFatalErrorsDialog .class , Duration .ofSeconds (5 )).clearAll ();
142
133
} catch (Exception e2 ) {
143
134
LOGGER .log (Level .INFO , "Second attempt to clear fatal errors dialog also failed." );
144
135
}
@@ -149,22 +140,18 @@ public void clearExceptions() {
149
140
* Open the 'Preferences' dialog
150
141
*/
151
142
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 ("//div[@accessiblename='Welcome screen categories']" ));
149
+ }
150
+ jTreeFixture .findText ("Customize" ).click ();
151
+ if (remoteRobot .isMac ()) {
152
+ resizeWelcomeWindow ();
167
153
}
154
+ remoteRobot .find (ContainerFixture .class , byXpath (XPathDefinitions .DIALOG_PANEL )).findText ("All settings" + '\u2026' ).click ();
168
155
}
169
156
170
157
/**
@@ -204,25 +191,10 @@ private void resizeWelcomeWindow() {
204
191
* @return fixture for the 'Tip Of the Day' dialog
205
192
*/
206
193
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 ();
226
198
return remoteRobot .find (TipDialog .class , Duration .ofSeconds (10 ));
227
199
}
228
200
@@ -239,45 +211,26 @@ public void disableNotifications() {
239
211
switchToProjectsPage ();
240
212
}
241
213
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
-
252
214
/**
253
215
* Switch to the 'Projects' page of flat welcome frame
254
216
*/
255
217
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 ( "//div[@accessiblename='Welcome screen categories']" ) );
262
224
}
225
+ jTreeFixture .findText (PROJECTS_BUTTON ).click ();
263
226
}
264
227
265
228
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 ;
281
234
}
282
235
}
283
236
@@ -293,16 +246,11 @@ private JButtonFixture welcomeFrameLink(String label) {
293
246
}
294
247
295
248
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 ));
297
250
}
298
251
299
252
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 );
306
254
307
255
// Clicks on X on first recent project to remove it from the recent projects list (visible only when hovered over with cursor)
308
256
recentProjects .runJs ("const horizontal_offset = component.getWidth()-22;\n " +
@@ -311,16 +259,12 @@ private void removeTopProjectFromRecentProjects() {
311
259
if (ideaVersionInt >= 20231 ) {
312
260
ComponentFixture removeDialog = remoteRobot .find (ComponentFixture .class , byXpath (XPathDefinitions .MY_DIALOG ), Duration .ofSeconds (10 ));
313
261
removeDialog .findText (ButtonLabels .REMOVE_FROM_LIST_LABEL ).click ();
314
- } else if ( ideaVersionInt >= 20203 ) { // Code for IntelliJ Idea 2020.3 or newer
262
+ } else {
315
263
List <JPopupMenuFixture > jPopupMenuFixtures = jPopupMenus (JPopupMenuFixture .Companion .byType ());
316
264
if (!jPopupMenuFixtures .isEmpty ()) {
317
265
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 ();
324
268
}
325
269
}
326
270
}
0 commit comments