Tuesday, 3 July 2018

TestNG Parameters

As we all know the value of Parameterization in automation testing. It allows us to automatically run a test case multiple times with various inputs and validation values. while creating a automation framework we need to put in some effort to support data driven testing in our automated tests. In this video we will see how we can parameterize a test case using TestNG parameters.

TestNG provides us interesting feature called TestNG Parameters. TestNG lets you pass parameters directly to your test methods with your testng.xml.

Video Tutorial -

How to do it?

Let me take a very simple example of Search on our site www.qaautomated.com, where the search text  is required to perform authentication.

1) Create a test case to perform Search which takes the one string argument as searchtext.

2) Provide searchtext as parameter using TestNG Annotation.

package test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.testng.annotations.Parameters;
public class TestNGParameters{
 private static WebDriver driver;
  public void test(String searchtext) throws InterruptedException {
   System.setProperty("webdriver.chrome.driver", "C:\\Softwares\\chromedriver_win32\\chromedriver.exe");
   driver=new ChromeDriver();

3) Provide Search text value in testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test thread-count="5" name="Test">
   <parameter name="searchtext" value="appium"/>
      <class name="test.TestNGParameters"/>
  </test> <!-- Test -->
</suite> <!-- Suite -->

4) Right click on testng.xml and run as TestNG Suit


  1. Thanks for your sharing. Hope you can contribute more quality posts to this page. Thank you!
    happy wheels

  2. AWS Training in Bangalore - Live Online & Classroom
    myTectra Amazon Web Services (AWS) certification training helps you to gain real time hands on experience on AWS. myTectra offers AWS training in Bangalore using classroom and AWS Online Training globally. AWS Training at myTectra delivered by the experienced professional who has atleast 4 years of relavent AWS experince and overall 8-15 years of IT experience. myTectra Offers AWS Training since 2013 and retained the positions of Top AWS Training Company in Bangalore and India.

    IOT Training in Bangalore - Live Online & Classroom
    IOT Training course observes iot as the platform for networking of different devices on the internet and their inter related communication. Reading data through the sensors and processing it with applications sitting in the cloud and thereafter passing the processed data to generate different kind of output is the motive of the complete curricula. Students are made to understand the type of input devices and communications among the devices in a wireless media.


    1. Great Article
      Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  3. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 

    java training in chennai | java training in bangalore

    java online training | java training in pune

    selenium training in chennai

    selenium training in bangalore

  4. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    Best AWS Training in Chennai | Amazon Web Services Training in Chennai

    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

    Amazon Web Services Training in Pune | Best AWS Training in Pune

  5. You blog post is just completely quality and informative. Many new facts and information which I have not heard about before. Keep sharing more blog posts.
    python training in chennai
    python training in Bangalore
    Python training institute in chennai

  6. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa interview questions and answers
    automation anywhere interview questions and answers
    blueprism interview questions and answers
    uipath interview questions and answers
    rpa training in chennai

  7. This comment has been removed by the author.

  8. Hello, I read your blog occasionally, and I own a similar one, and I was just wondering if you get a lot of spam remarks? If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.
    Android Training in Chennai
    Selenium Training in Chennai
    Devops Training in Chennai

  9. And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.

  10. I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so speedy.
    data analytics course malaysia

  11. Hi Anuja Bhatt, i glad to find your post. Keep up the good work. Thanks for very useful content. I'm on a similar path to yourself but for me i'm teaching myself test automation and sharing my progress so as to encourage others to do same and upskill to meet with our demanding ever changing industry. Check out my journey @ http://teachyourselftestautomation.com/. Stay blessed

  12. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
    artificial intelligence course in kompally