Create Test Case using Selenium

Price: INR 8,999.00
Price: INR 14,999.00
Was: INR 16,999.00

Here, We are going to understand, How can we create the automation Test case using selenium. We are going to create our first Automation Test Script using Selenium WebDriver.


As you know Selenium is an Automation Testing Tool. We can use Selenium standalone to create the Testcase using java class but it’s not worth to use selenium alone. We will see how professionals use the Selenium to automate the projects. We have already learned TestNG and JUnit.(If not then it is recommended to go through with any of these first). We are going to use Selenium with TestNG testing framework.


Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.


Selenium Automation Test Script

Let’s understand this with a simple example. We automate the Manual Testcase into Automation Script using selenium i.e we convert the plain English manual test case into automation script using selenium.

Note – As we declared we have picked Java as the programming language to code selenium and we are the using TestNG framework with Selenium.


Manual Test Scenario

  1. Open the Browser.
  2. Enter the configured website URL. (Yahoo site)
  3. Verify the “Home Page” title.
  4. Close the browser.


So above-mentioned our Manual Test case. Now the question is, How we can code this test into Automation Script.

Let’s try to understand the above example. Look at the example carefully and try to understand it. Here we are using the TestNG with Selenium Webdriver to automate the Testing.


In the very first method invokeBrowser() we are invoking the browser. We have kept that code inside the @BeforeTest annotation. So it will invoke the browser before start the execution of Test case.

In Second Method verifyTitle() , We have kept our test case code. Here we are opening the and verifying the Yahoo page title.

In Last Method closeBrowser() , we are closing the browser after completion of our test case.


Now let’s run our test case(Run TestNG Test) and look at the Report (View TestNG Report)

Selenium Sample Test


This HTML report of our test case (You can also see the test report in Eclipse console). So we can see, our test case result is the pass.

Now copy this code and run on your machine. After the first run changes the expected result and again run and verify the report, You Test should fail.(If you are getting any compilation error in your eclipse the mouse hover on the error line and import the target library)

So this is our first Test Case in selenium. I hope it was your nice experience with EasyBix. If you have any query in above code or example, You can write us.

0 Comment

Leave a Reply