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

16 comments:

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


    R Training in Chennai

    ReplyDelete
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. Great post! I am see the programming coding and step by step execute the outputs.I am gather this coding more information.It's helpful for me my friend. Also great blog here with all of the valuable information you have.
    Great post! I am see the programming coding and step by step execute the outputs.I am gather this coding more information.It's helpful for me my friend. Also great blog here with all of the valuable information you have.
    aws training in chennai | aws training in annanagar | aws training in omr | aws training in porur | aws training in tambaram | aws training in velachery

    ReplyDelete
  9. Thank you for taking the time to discuss this informative content with us. I feel happy about the topic that you have shared with us.
    AWS training in chennai | AWS training in anna nagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

    ReplyDelete
  10. I genuinely appreciated understanding it. Sitting tight for some more incredible articles like this from you in the nearing days.

    Big Data Hadoop Online Training
    Online training for big data

    ReplyDelete

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...