3030import com .redhat .devtools .intellij .commonuitest .fixtures .dialogs .information .TipDialog ;
3131import com .redhat .devtools .intellij .commonuitest .fixtures .dialogs .settings .SettingsDialog ;
3232import com .redhat .devtools .intellij .commonuitest .fixtures .dialogs .settings .pages .NotificationsPage ;
33+ import com .redhat .devtools .intellij .commonuitest .utils .constans .XPathDefinitions ;
3334import org .apache .commons .io .FileUtils ;
3435import org .jetbrains .annotations .NotNull ;
3536
4950 *
5051 * @author zcervink@redhat.com
5152 */
52- @ DefaultXpath (by = "FlatWelcomeFrame type" , xpath = "//div[@class='FlatWelcomeFrame']" )
53+ @ DefaultXpath (by = "FlatWelcomeFrame type" , xpath = XPathDefinitions . FLAT_WELCOME_FRAME )
5354@ FixtureName (name = "Welcome To IntelliJ IDEA Dialog" )
5455public class FlatWelcomeFrame extends CommonContainerFixture {
5556 private static final Logger LOGGER = Logger .getLogger (FlatWelcomeFrame .class .getName ());
56- private static final String JBLIST_XPATH = "//div[@class='JBList']" ;
57- private static final String TREE_XPATH = "//div[@class='Tree']" ;
5857 private static final String PROJECTS_BUTTON = "Projects" ;
5958 private final RemoteRobot remoteRobot ;
6059 private final UITestRunner .IdeaVersion intelliJVersion ;
@@ -94,8 +93,7 @@ public void clickOnLink(String label) {
9493 * Clear the workspace by deleting the content of the IdeaProjects folder and clearing all the projects' links in the 'Welcome to IntelliJ IDEA' dialog
9594 */
9695 public void clearWorkspace () {
97- List <JListFixture > jListFixtures = jLists (byXpath ("//div[@accessiblename='Recent Projects']" ));
98-
96+ List <JListFixture > jListFixtures = jLists (byXpath (XPathDefinitions .RECENT_PROJECTS ));
9997 for (int i = 0 ; i < projectsCount (); i ++) {
10098 JListFixture recentProjectsList = jListFixtures .get (0 );
10199 recentProjectsList .runJs ("const horizontal_offset = component.getWidth()-22;\n " +
@@ -150,13 +148,13 @@ public void openSettingsDialog() {
150148 HeavyWeightWindowFixture heavyWeightWindowFixture = find (HeavyWeightWindowFixture .class , Duration .ofSeconds (5 ));
151149 heavyWeightWindowFixture .findText ("Preferences" ).click ();
152150 } else if (ideaVersion <= 20212 ) {
153- JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (JBLIST_XPATH ));
151+ JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (XPathDefinitions . JBLIST ));
154152 jListFixture .clickItem ("Customize" , false );
155- remoteRobot .find (ContainerFixture .class , byXpath ("//div[@class='DialogPanel']" )).findText ("All settings" + '\u2026' ).click ();
153+ remoteRobot .find (ContainerFixture .class , byXpath (XPathDefinitions . DIALOG_PANEL )).findText ("All settings" + '\u2026' ).click ();
156154 } else {
157- JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (TREE_XPATH ));
155+ JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions . TREE ));
158156 jTreeFixture .findText ("Customize" ).click ();
159- remoteRobot .find (ContainerFixture .class , byXpath ("//div[@class='DialogPanel']" )).findText ("All settings" + '\u2026' ).click ();
157+ remoteRobot .find (ContainerFixture .class , byXpath (XPathDefinitions . DIALOG_PANEL )).findText ("All settings" + '\u2026' ).click ();
160158 }
161159 }
162160
@@ -175,13 +173,13 @@ public TipDialog openTipDialog() {
175173 HeavyWeightWindowFixture heavyWeightWindowFixture = find (HeavyWeightWindowFixture .class , Duration .ofSeconds (5 ));
176174 heavyWeightWindowFixture .findText ("Tip of the Day" ).click ();
177175 } else if (ideaVersion <= 20212 ) {
178- JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (JBLIST_XPATH ));
176+ JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (XPathDefinitions . JBLIST ));
179177 jListFixture .findText ("Learn IntelliJ IDEA" ).click ();
180- remoteRobot .find (JLabelFixture .class , byXpath ("//div[@text='Tip of the Day']" )).click ();
178+ remoteRobot .find (JLabelFixture .class , byXpath (XPathDefinitions . TIP_DIALOGA_2 )).click ();
181179 } else {
182- JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (TREE_XPATH ));
180+ JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions . TREE ));
183181 jTreeFixture .findText ("Learn IntelliJ IDEA" ).click ();
184- remoteRobot .find (JLabelFixture .class , byXpath ("//div[@text='Tip of the Day']" )).click ();
182+ remoteRobot .find (JLabelFixture .class , byXpath (XPathDefinitions . TIP_DIALOGA_2 )).click ();
185183 }
186184
187185 return remoteRobot .find (TipDialog .class , Duration .ofSeconds (10 ));
@@ -199,10 +197,10 @@ public void disableNotifications() {
199197 settingsDialog .ok ();
200198
201199 if (ideaVersion >= 20213 ) {
202- JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (TREE_XPATH ));
200+ JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions . TREE ));
203201 jTreeFixture .findText (PROJECTS_BUTTON ).click ();
204202 } else if (ideaVersion >= 20203 ) {
205- JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (JBLIST_XPATH ));
203+ JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (XPathDefinitions . JBLIST ));
206204 jListFixture .clickItem (PROJECTS_BUTTON , false );
207205 }
208206 }
@@ -216,18 +214,18 @@ public void preventTipDialogFromOpening() {
216214 tipDialog .close ();
217215
218216 if (ideaVersion >= 20213 ) {
219- JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (TREE_XPATH ));
217+ JTreeFixture jTreeFixture = remoteRobot .find (JTreeFixture .class , byXpath (XPathDefinitions . TREE ));
220218 jTreeFixture .findText (PROJECTS_BUTTON ).click ();
221219 } else if (ideaVersion >= 20203 ) {
222- JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (JBLIST_XPATH ));
220+ JListFixture jListFixture = remoteRobot .find (JListFixture .class , byXpath (XPathDefinitions . JBLIST ));
223221 jListFixture .clickItem (PROJECTS_BUTTON , false );
224222 }
225223 }
226224
227225 private int projectsCount () {
228226 try {
229- ContainerFixture projectWrapper = find (ContainerFixture .class , byXpath ("//div[@class='NewRecentProjectPanel']" ));
230- JListFixture projectList = projectWrapper .find (JListFixture .class , byXpath ("//div[@class='MyList']" ));
227+ ContainerFixture projectWrapper = find (ContainerFixture .class , byXpath (XPathDefinitions . NEW_RECENT_PROJECT_PANEL ));
228+ JListFixture projectList = projectWrapper .find (JListFixture .class , byXpath (XPathDefinitions . MY_LIST ));
231229 return projectList .collectItems ().size ();
232230 } catch (WaitForConditionTimeoutException e ) {
233231 return 0 ;
@@ -236,13 +234,13 @@ private int projectsCount() {
236234
237235 // Works for IntelliJ Idea 2020.3+
238236 private JButtonFixture welcomeFrameLink (String label ) {
239- if (UtilsKt .hasAnyComponent (this , byXpath ("//div[@class='NewRecentProjectPanel']" ))) {
240- return button (byXpath ("//div[@class=' JBOptionButton' and @text='" + label + "']" ), Duration .ofSeconds (2 ));
237+ if (UtilsKt .hasAnyComponent (this , byXpath (XPathDefinitions . NEW_RECENT_PROJECT_PANEL ))) {
238+ return button (byXpath (XPathDefinitions . JBOptionButton ( label ) ), Duration .ofSeconds (2 ));
241239 }
242- return button (byXpath ("//div[@class='NonOpaquePanel'][./div[@text='" + label + "']]" ), Duration .ofSeconds (2 ));
240+ return button (byXpath (XPathDefinitions . NonOpaquePanel ( label ) ), Duration .ofSeconds (2 ));
243241 }
244242
245243 private ComponentFixture ideErrorsIcon () {
246- return find (ComponentFixture .class , byXpath ("//div[@class='IdeErrorsIcon']" ), Duration .ofSeconds (10 ));
244+ return find (ComponentFixture .class , byXpath (XPathDefinitions . IDE_ERROR_ICON ), Duration .ofSeconds (10 ));
247245 }
248246}
0 commit comments