Google+

318. Renaming the Projects and its items using Eclipse IDE 'Refactor' option






There may be situations while working with Selenium Automation that you may have to change the name of the project you have created in Eclipse IDE. So it is required to learn how to rename a Project.

Before renaming any project using Eclipse IDE 'Re-factor' option lets create a basic Selenium WebDriver project as shown below:

Before Renaming:

1. Create a new Project say 'WebDriver-ProjectX' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'packageX' under the newly created project.
4. Create a Java Class file say 'ClassX' under the newly created package as shown below:



5. Write the following code into the newly created Java Class file 'ClassX.java' as shown below and make sure that you resolve all the errors before going to next step:




6. Save and Run the 'ClassX.java' file by selecting the 'JUnit Test' option and ensure that http://www.Selenium143.blogspot.com website is opened as shown below:




7. Also ensure that Test got passed in the Eclipse IDE as shown below:




Rename the Project Name 'ProjectX' with 'ProjectY':

1. Right click on the Project 'ProjectX' as shown below and select 'Refactor' -> 'Rename' option as shown below :




2. Ensure that Rename Project Name dialog is displayed as shown below:



3. Replace 'WebDriver - ProjectX' with 'WebDriver - ProjectY' text in the 'New Name' text box field as shown below and click on 'OK' button:

4. Ensure that the Project name is now changed to 'WebDriver - ProjectY' as shown below:




Rename the Package Name 'Package_X' with 'Package_Y':

1. Right click on the Package 'PackageX' as shown below and select 'Refactor' -> 'Rename' option as shown below :




2. Ensure that Rename Package dialog is displayed as shown below:


3. Replace 'PackageX' with 'PackageY' text in the 'New Name' text box field as shown below and click on 'OK' button:



4. Ensure that the Package name is now changed to 'PackageY' as shown below:





Rename the Class Name 'ClassX' with 'ClassY':

1. Right click on the Class 'ClassX' as shown below and select 'Refactor' -> 'Rename' option as shown below :




2. Ensure that Rename Compilation Unit dialog is displayed as shown below:


3. Replace 'ClassX' with 'ClassY' text in the 'New Name' text box field as shown below and click on 'Finish' button:


4. Ensure that the Class name is now changed to 'ClassY' as shown below:




Rename the Folder Name 'lib' with 'libraries':

1. Right click on the folder 'lib' as shown below and select 'Refactor' -> 'Rename' option as shown below :



2. Ensure that Rename Resources dialog is displayed as shown below:



3. Replace 'lib' with 'libraries' text in the 'New Name' text box field as shown below and click on 'Finish' button:



4. Ensure that the folder name is now changed to 'libraries' as shown below:



5. After renaming the folder above, open the Java Class file and observe that there are few errors displayed as shown below:




6. This is because the Jar files under the libraries folder are got disconnected from the project after renaming it. Please follow the next steps in order to connect them again with the Project again.

7. Right click on the Project and select Properties option as shown below:




8. Ensure that 'Properties for 'WebDriver - ProjectY' dialog is displayed, select all the JAR files that are displayed with errors and click on 'Remove' button as shown below:



9. Ensure that all the Selected JAR files got removed and click on 'Add Jars' button as shown below:



10. Ensure that JAR Selection dialog is displayed, expand the WebDriver - ProjectY -> libraries folder, select all the JAR files and click on 'OK' button as shown below:



11. Ensure that all the selected JAR files got added in the 'Properties For WebDriver - ProjectY' dialog and click on 'OK' button as shown below:



12. Now observe that all the Errors in Java Class file got resolved as shown below:




13. Save and Run the 'ClassY.java' file by selecting the 'JUnit Test' option and ensure that http://www.Selenium143.blogspot.com website is opened as shown below:




21. Also ensure that Test got passed in the Eclipse IDE as shown below:





So now its confirmed that our Tests got run successfully after renaming the Project Name, Package Name, Class Name and Libraries folder name.





Please comment below to feedback or ask questions.

Refactoring the Selenium Automation Code will be explained in the next post.




No comments: