Lets now start writing Selenium Automation Test Script for above identified tests and in the upcoming posts we can Refactor the code written in this post for better organization of code.
Lets Implement the Non-Refactored Selenium Automation Code for the above identified tests:
Pre-requisites:
1. Create a new Project say 'RC-Project16' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Start the Selenium Standalone Server
5. Create a package say 'package16' under the newly created project.
6. Create a Java Class file say 'Class16' under the newly created package as shown below:
1. Create a new Project say 'RC-Project16' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Start the Selenium Standalone Server
5. Create a package say 'package16' under the newly created project.
6. Create a Java Class file say 'Class16' under the newly created package as shown below:
Actual Steps:
1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:
1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:
2. Start the Selenium Standalone Server
3. Save and Run the 'Class16.java' file by selecting the 'JUnit Test' option and ensure that the test is passed as shown below: (This means that our test has verified that the 'Selenium: Beginners Guide' heading text, 'Assert that this text is on the page' text and 'Home Page' link are available on the specified page)
3. Save and Run the 'Class16.java' file by selecting the 'JUnit Test' option and ensure that the test is passed as shown below: (This means that our test has verified that the 'Selenium: Beginners Guide' heading text, 'Assert that this text is on the page' text and 'Home Page' link are available on the specified page)
Download This Project:
Click here to download this project and import into Eclipse IDE on your machine.
At this point we've to understand that, we've written 3 tests in a single test method as shown below:
Is it ok to write three tests in a single Test method instead of writing them in separate test methods?
The answer is No. Though the Test runs without any errors even if we mention more than one tests in a single test method, its not a good practice to write more than one test into a single test method.
So what we have to do in order to overcome this ?
We've to write each and every test into a separate test method.
Please comment below to feedback or ask questions.
Only one test should be written inside a single test method will be explained in the next post.
No comments:
Post a Comment