321. Non-Refactored Selenium Automation code for the tests identified in previous post

In previous post, we've identified 3 tests for Selenium Automation (Refer to Post #45 ).

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:


1. Create a new Project say 'RC-Project15' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package15' under the newly created project.
4. Create a Java Class file say 'Class15' 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:

2. Write the WebDriver code for all the 3 tests explained in our previous post (Refer to Post #45 ) as shown below:

3. Save and Run the '' 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: