Can I run TestNG using Command Prompt

0 votes
I want to run TestNG using command prompt. How can I do it?
Jun 19, 2019 in Selenium by Himanshi

1 answer to this question.

+1 vote

Hey Himanshi, you can run testNG with command prompt by using following line of commands:


set classpath=C:\Users\Admin\Desktop\Ruksar\workspace\TestNG\bin;C:\Users\Admin\Desktop\Ruksar\workspace\TestNG\lib\*
java org.testng.TestNG C:\Users\Admin\Desktop\Ruksar\workspace\TestNG\testng.xml
answered Jun 20, 2019 by Abha
• 28,060 points

I've tried this so  many time but I keep getting a same error.  Can you please help.  I've read all the posts I can find online, but nothing is helping.

C:\Eclipse\WorkSpace\TestingPractice>set classpath=C:\Eclipse\WorkSpace\TestingPractice\bin\;C:\Eclipse\WorkSpace\TestingPractice\lib\*
C:\Eclipse\WorkSpace\TestingPractice>java org.testng.TestNG C:\Eclipse\WorkSpace\TestingPractice\testng.xml

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/Stage
        at org.testng.internal.Configuration.<init>(
        at org.testng.TestNG.init(
        at org.testng.TestNG.<init>(
        at org.testng.TestNG.privateMain(
        at org.testng.TestNG.main(
Caused by: java.lang.ClassNotFoundException:
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
        at java.base/java.lang.ClassLoader.loadClass(
        ... 5 more

Add the google-guice-core dependency in the pom.xml.


or download the jar here and add it to the classpath.

Thank you so much for a quick reply.  I'm very new to selenium, I have not used maven yet.  Can we not run testng file from command line without using maven?

Thanks again
Thank you so much for assisting, I didn't have to have POM.xml but I did need to download the guice-4.2.2.jar and add it to lib folder.  Once I did that, it worked.

Once again thank you.

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How can I run/debug pytest script using eclipse?

Hi Amish, to run/debug pytest scripts in ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,060 points
+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this It deals with a similar ...READ MORE

answered Jan 13, 2020 in Selenium by Karan
• 19,620 points
0 votes
1 answer

How can I run test cases in parallel using Keyword Driven Framework?

One solution to try for executing test ...READ MORE

answered Jun 29, 2020 in Selenium by Alexander
0 votes
2 answers

What is the role of TestNG & JUnit frameworks in Selenium?

TestNG and JUnit are test frameworks . it ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
0 votes
1 answer

Diff between WebDriver listeners and TestNG listeners?

This is not a very important concept ...READ MORE

answered Apr 14, 2018 in Selenium by king_kenny
• 3,710 points
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
0 votes
1 answer
0 votes
1 answer

How can I send some data to a Prompt Alert box using Selenium Webdriver?

Hey Abhishek, you can use sendKeys() method ...READ MORE

answered Jul 3, 2019 in Selenium by Abha
• 28,060 points