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.
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.
3) Provide Search text value in testng.xml
4) Right click on testng.xml and run as TestNG Suit
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; @Parameters("searchtext") @Test public void test(String searchtext) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "C:\\Softwares\\chromedriver_win32\\chromedriver.exe"); driver=new ChromeDriver(); driver.get("http://www.qaautomated.com"); Thread.sleep(5000); driver.findElement(By.xpath("*//input[@class='search-field']")).sendKeys(searchtext); driver.findElement(By.xpath("*//input[@class='search-submit']")).click(); driver.quit(); } }
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"/> <classes> <class name="test.TestNGParameters"/> </classes> </test> <!-- Test --> </suite> <!-- Suite -->
4) Right click on testng.xml and run as TestNG Suit
Thanks for your sharing. Hope you can contribute more quality posts to this page. Thank you!
ReplyDeletehappy wheels
Very nice information. I got a better information from you. I would like to appreciate you.
ReplyDeleteBest Data Science Online Training Institute In Hyderabad | Online Data Science Training
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
ReplyDeleteData Science Training in Chennai
Data science training in bangalore
online Data science training
Data science training in pune
Data science training in kalyan nagar
Data science training in Bangalore
Data science training in tambaram
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..
ReplyDeletejava training in chennai | java training in bangalore
java online training | java training in pune
selenium training in chennai
selenium training in bangalore
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.
ReplyDeletepython training in chennai
python training in Bangalore
Python training institute in chennai
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.
ReplyDeleterpa interview questions and answers
automation anywhere interview questions and answers
blueprism interview questions and answers
uipath interview questions and answers
rpa training in chennai
Well you use a hard way for publishing, you could find much easier one!
ReplyDeleteangularjs Training in marathahalli
angularjs interview questions and answers
angularjs Training in bangalore
angularjs Training in bangalore
angularjs online Training
This comment has been removed by the author.
ReplyDeleteI hope this article will slove my doubts and surely i will follow this and i expect that you will update more in future.
ReplyDeleteiOS Training in Chennai
Big Data Training in Chennai
Hadoop Training in Chennai
Android Training in Chennai
Selenium Training in Chennai
Digital Marketing Training in Chennai
JAVA Training in Chennai
German Classes in chennai
SEO Training in Chennai
SEO Course in Chennai
SEO Training in velachery
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.
ReplyDeleteAndroid Training in Chennai
Selenium Training in Chennai
Devops Training in Chennai
very kind of you. good information. great work
ReplyDeleteJava Training | Java Training Institute | Java Training in Chennai | Java Training Institute in Chennai
Php Training | Php Training in Chennai | Php Training Institute in Chennai | Php Training Institute
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.
ReplyDeletedata analytics course malaysia
Excellent post!!! It was very interesting and very comprehensive post. Well done post and Keep doing...
ReplyDeleteCorporate Training in Chennai
Corporate Training institute in Chennai
Corporate Training in Chennai
Social Media Marketing Courses in Chennai
Job Openings in Chennai
Oracle Training in Chennai
Tableau Training in Chennai
Power BI Training in Chennai
Corporate Training in Tambaram
Corporate Training in OMR
Great Article. Thank you for sharing! Really an awesome post for every one.
ReplyDeleteProject Centers in Chennai
JavaScript Training in Chennai
Final Year Project Domains for IT
JavaScript Training in Chennai
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
ReplyDeletenice..
ReplyDeleteinplant training in chennai
inplant training in chennai
inplant training in chennai for it
hosting
india hosting
india web hosting
iran web hosting
technology 11 great image sites like imgur hosting
final year project dotnet server hacking what is web hosting
macao web hosting
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!
ReplyDeleteartificial intelligence course in kompally
ReplyDeleteGreat 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
Great Article
ReplyDeleteCloud 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
Sharing the same interest, Infycle feels so happy to share our detailed information about all these courses with you all! Big data training in chennai & get to know everything you want to about software trainings.
ReplyDeleteWorth reading! Our experts also have given detailed inputs about these trainings & courses! Presenting here for your reference. Do checkout
ReplyDeleteaws training in chennai & enjoy learning more about it.
Excellent content! Thanks for sharing such a useful information.
ReplyDeletePython Training Institute in Pune
Best Python Classes in Pune