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 RC project as shown below:
Before Renaming:
1. Create a new Project say 'RC-ProjectX' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Create a package say 'package_X' under the newly created project.
5. Create a Java Class file say 'ClassX' under the newly created package as shown below:
7. Start the Selenium Standalone Server
8. 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:
9. 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 'ProjectX' with '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 '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:
4. Ensure that the Package name is now changed to 'Package_Y' 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 'libraries' with 'librariesY':
1. Right click on the folder 'libraries' as shown below and select 'Refactor' -> 'Rename' option as shown below :
2. Ensure that Rename Resources dialog is displayed as shown below:
3. Replace 'libraries' with 'librariesY' 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 'librariesY' 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 librariesY 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 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:
12. Now observe that all the Errors in Java Class file got resolved as shown below:
13. Start the Selenium Standalone Server and observe that an error dialog is displayed as shown below:
14. Click on 'OK' button on the above error dialog and follow the next steps to resolve this problem.
15. Select 'External Tools Configuration' as shown below:
16. Ensure that 'External Configurations dialog is displayed, select 'Selenium Standalone Server' program and click on 'Browse Workspace' button under the 'Working Directory' label as shown below:
17. Ensure that the folder selection dialog is displayed, expand the ProjectY, select the librariesY folder and click on 'OK' button as shown below:
18. Ensure that the Path in the Working Directory text box is now changed to librariesY folder and Click on 'Apply' Button followed by 'Run' Button in the External Tools Configuration dialog as shown below:
19. Observe that Selenium Standalone Server has started without any errors as shown below:
20. 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:
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:
Post a Comment