Friday, July 7, 2017

How to execute selenium test cases from Command Prompt using testng.xml?

We know how to execute the test cases from IDE like eclipse o IntelliJ. We just have to either right click on the test case and select the Run option or right right click on the testng.xml file and select TestNG --> Run as --> TestNG suite option.

In this post we will learn how to execute the scripts from command prompt.

Step 1: Create a TestNG project.

Step 2: Go to project home directory path, create a folder say libs and keep the required TestNG and Selenium jar file as shown below.


You can download Selenium Jar file from click here. And the TestNG jar files (testng.jar and jcommander.jar) can be taken from the eclipse plugins location as show below.


 Add these three jar files in the Java Build Path


Step 3: Create a sample Selenium test as shown below.  Please copy and paste the below code in the test you created.

This sample selenium test launches Google application and searches for the Selenium Babu Page


Step 4: Create a testng.xml file to run the test. Please refer my previous post How to create testng.xml? to know how to create it.


On the next popup window, click OK. The testng.xml should be created, you can verify it in eclipse and project directory path. You should is the testng.xml file in the project directory path.


Step 5: Open the command prompt, and follow the below steps one by one to run the testng.xml file through command prompt.


You should is the test execution starting, launching Firefox, opening the Facebook application and then closing the browser. You can observe the results now in the command prompt

That’s it, this is how we can execute TestNG tests through command prompt.

Thanks for reading. Hope this post helped you to execute the testng.xml from command prompt.

#HappyLearning #HappyTesting #qababu

24 comments:

  1. The future of automation testing tool is on the positive tool. As the demand of quality web application keeps on increasing, the tool like Selenium IDE is getting very popular all over the world. Thus, taking Selenium Training in Chennai will help you to enter software testing industry.Best Selenium training institute in Chennai

    ReplyDelete
  2. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.

    software testing course in chennai

    ReplyDelete
  3. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
    Best Python training Institute in chennai

    ReplyDelete
  4. This is Very Useful blog, Thank you to Share this.


    R Training in Chennai

    ReplyDelete
  5. Such a great word which you use in your article and article is amazing knowledge. thank you for sharing it.

    Looking for Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT software course in Bangalore, India. Also it provides placement assistance service in Bangalore for IT.
    Best Software Training Institute in Bangalore

    ReplyDelete
  6. And also thanks for sharing this informative. Keep it Sir and I am waiting for your next post on your site blog.

    Best Training Institute in Bangalore BTM. My Class Training Bangalore training center for certified course, learning on Software Training Course by expert faculties, also provides job placement for fresher, experience job seekers.
    Software Training Institute in Bangalore

    ReplyDelete
  7. Post is very useful. Thank you, this useful information.

    Start your journey with Training Institute in Bangaloreand get hands-on Experience with 100% Placement assistance from Expert Trainers with 8+ Years of experience @eTechno Soft Solutions Located in BTM Layout Bangalore.
    SAP Training in Bangalore

    ReplyDelete
  8. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.

    ReplyDelete
  9. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.sap hana training in bangalore

    ReplyDelete
  10. Awesome,Thank you so much for sharing such an awesome blog. sap hr training in bangalore

    ReplyDelete
  11. Thanks for sharing this blog. This very important and informative blog.sap mm training in bangalore

    ReplyDelete
  12. Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind. sap fico training in bangalore


    ReplyDelete
  13. I think this is one of the most significant information for me. And i’m glad reading your article. Thanks for sharing!

    Learn Hadoop Training from the Industry Experts we bridge the gap between the need of the industry. Softgen Infotech provide the Best Hadoop Training in Bangalore with 100% Placement Assistance. Book a Free Demo Today.
    Big Data Analytics Training in Bangalore
    Tableau Training in Bangalore
    Data Science Training in Bangalore
    Workday Training in Bangalore

    ReplyDelete
  14. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.

    ReplyDelete
  15. Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.sap hana training in bangalore


    ReplyDelete
  16. Awesome,Thank you so much for sharing such an awesome blog. sap hr training in bangalore

    ReplyDelete
  17. Thanks for sharing this blog. This very important and informative blog.sap mm training in bangalore

    ReplyDelete
  18. Learned a lot of new things from your post! Good creation and HATS OFF to the creativity of your mind. sap fico training in bangalore


    ReplyDelete

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...