Error executing testng.xml through CLI : Could not find or load main class org.testng.TestNG

The simplest way to execute your testng.xml is as follows :

  • Get your Project Location from your IDE i.e. Eclipse, through Windows Explorer go to the Project Location and create a directory lib .
  • Dump all the libraries (Selenium jars, TestNG) in the lib directory.
  • From Project Directory, through CLI provide the following classpath:

    C:\Users\keating99\workspace\FdimTests>set classpath=C:\Users\keating99\workspace\FdimTests\bin;C:\Users\keating99\workspace\FdimTests\lib\*;
    
  • Now, execute testng.xml as follows :

    C:\Users\keating99\workspace\FdimTests>java org.testng.TestNG testng.xml
    
  • Observe the Testcase gets executed.

Leave a Comment