Unable to execute the testng.xml file through cmd prompt window.

609 views
Skip to first unread message

Kolusu Bindu

unread,
Jun 5, 2018, 10:44:50 PM6/5/18
to Selenium Users
Hi Everyone,

I have been looking for various posts to resolve my issue, but no luck. I'm able to execute testng.xml file in eclipse IDE and it is working without any errors or classpath issues. But when I try to execute the same XML file through cmd line it is throwing below error:
 

Microsoft Windows [Version 10.0.16299.431]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\viju4>cd C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins

C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins>set classpath=C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins\bin;

C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins>set classpath=C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins\lib\*;

C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins>java org.testng.TestNG testng.xml
[TestNG] [ERROR]
Cannot find class in classpath: com.vijay.jenkins.Demo
Exception in thread "main" java.lang.NullPointerException
        at org.testng.TestNG.getStatus(TestNG.java:211)
        at org.testng.TestNG.main(TestNG.java:1324)

C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\com.bindu.jenkins>

Please help me resolve this issue. And I would like to know the list of jar files should be included in the lib.jar file in the project directory.

Regards,
Bindu.

Krishnan Mahadevan

unread,
Jun 5, 2018, 10:49:38 PM6/5/18
to seleniu...@googlegroups.com

Bindu,

 

This is not a Selenium question. Please help keep this forum relevant by posting queries that are ONLY related to Selenium.

 

You should be posting your query on the testng-users google forums.

 

Now to answer your question:

You are having a CLASSPATH issue. TestNG is not able to find your CLASSES. Is there any specific reason as to why you would want to run your code only via a “java “ command instead of using a build tool such as [Maven/Gradle] ? If there is no specific reason, I would suggest that you please spend sometime learning about a build tool and run your tests using the build tool. Managing the classpath is a lot more easier in those cases.

 

With respect to that NullPointerException that you are seeing, that’s a bug. I have fixed it as part of https://github.com/cbeust/testng/pull/1811

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c6938c4b-a832-4fc2-844f-9f8f3972fd33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kolusu Bindu

unread,
Jun 6, 2018, 11:47:39 AM6/6/18
to seleniu...@googlegroups.com
Sorry for posting this issue here, I wanted to run a batch file through Jenkins. But it is throwing the same error in Jenkins too. And when i double click on the batch file i created still same error. But it is working fine in eclipse IDE, it is just executing the SysOut Statement and giving the following message in the 
command window.


C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\Jenkins>java -cp C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\Jenkins\lib\*;C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\Jenkins\bin org.testng.TestNG C:\Users\viju4\Desktop\selenium\Selenium_Scripts\FIRST_Test_Script\Jenkins\demo1_testng.xml
Hi bindu

===============================================
Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

In ECLIPSE IDE:

[RemoteTestNG] detected TestNG version 6.14.2
Hi bindu 
Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 29163
Only local connections are allowed.
Jun 06, 2018 11:43:42 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
The title of the page is Facebook - Log In or Sign Up

===============================================
Suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================

kindly help to resolve this issue.

Regards,
Bindu.


To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/3241A915-8EA9-4A5E-8454-57E3D07174BA%40gmail.com.

Sagar Kale

unread,
Jun 3, 2019, 5:29:22 AM6/3/19
to Selenium Users
Had the same problem. I think TestNG changes the classpath variable and moves all class files to /target/classes directory. But if we try to point this path in cmd, it doesnt work. For bat file to run all class files HAVE to be in bin folder. Do the following

Goto Eclipse -> right click on Project ->Properties -> Source tab

Here, change the output folder to bin. Now run the testng xml from eclipse to make sure everything still works.

Then goto bin folder, your class files should now be here. Then run your testng command, should start working.
Reply all
Reply to author
Forward
0 new messages