0

I followed the instructions given in this post. But I get the message "Could not find or load main class org.testng.TestNG

Running test from CMD is quite easy.

Follow below steps

1- Go to home directory and Set class path

Home Directory > set classpath=Home Directory\bin; and press enter

Home Directory > set classpath=Home Directory\lib*; and press enter

2-Home-directory > java org.testng.TestNG testng.xml

http://learn-automation.com/execute-selenium-test

1 Answer 1

2

You are overwriting the classpath you are setting in first statement (set classpath=Home Directory\bin) by second statement (set classpath= Home Directory\lib*)

What you can do is combine both separated with semicolon (;) set classpath=HomeDirectory\lib*;HomeDirectory\bin;

You can check what classpath is getting saved finally by just using 'set'

Sign up to request clarification or add additional context in comments.

5 Comments

Ishan, I did follow your recommendation. I get the following error. C:\Java\Selenium\LearningSelenium>java org,testng.TestNG C:\Java\Selenium\LearningSelenium\xmlfiles\CETesting.xml Error: Could not find or load main class org,testng.TestNG
I think you should be including the place where your testng jar is present.
if that is not present in your HomeDirectory\lib. Say if your testng jar is present in HomeDirectory\Testng\testng.jar Try with -cp to mention the classpath. Try: java -cp "HomeDirectory\lib*;HomeDirectory\bin;HomeDirectory\Testng\testng.jar" org.testng.TestNG testng.xml
Ishan, the testng.jar exists in lib folder. but I still get the same error that it can't load main class org.testng.TestNG. C:\Java\Selenium\LearningSelenium\lib>java org.testng.TestNG C:\Java\Selenium\LearningSelenium\xmlfiles\CETesting.xml Error: Could not find or load main class org.testng.TestNG
qtp-automate.blogspot.com/2011/10/… this link was very helpful

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.