Getting started with Selenium Web Driver in Java and TestNG

Share
selenium-testng


Selenium is one of the best automation tools in the market.
TestNG is the next generation Java Unit Testing framework.

Together they can be used to automate a lot of applications having a GUI.




The Installation guide

You will need the following:
  1. Eclipse
  2. Selenium
  3. TestNG
  4. Firefox

Installing Eclipse
You can install Eclipse  by downloading the zip package from Eclipse Foundation. Choose Eclipse IDE for JAVA EE Developers. Make sure you have Java 1.7 installed on your machine before you start eclipse.


Installing Selenium

Download the Selenium Java zip from Selenium Java downloads.


Installing TestNG

Start Eclipse and the installation are present here: http://testng.org/doc/eclipse.html


Bring it all together - Automating a Google Search in Selenium

1. Start Eclipse and create a project.
2. Make sure you add all the jar files downloaded from Selenium, including those present in libs folder. Also add the TestNG library.
3. Create a class GoogleSearch and add the following contents
4. Run the project as a TestNG test.


How things work?
Since TestNG is similar to JUnit, magic is done with the help of annotations. See this TestNG annotations
.

If everything goes well, a search query will be entered in the Google search box.

2 comments :

Unknown said...

Very Nice and Very helpful for beginners like us. Thanks Again..

Unknown said...

Please explain TestNG more for beginners with Selenium webdriver.

Post a Comment

Written by Sundeep Machado © 2007 - 2018 Sundeep Machado

You can get in touch with him on and Twitter