RE: Execute my Selenium Webdriver scripts in command line

Hello, I don’t know if this post was already asked but I need to execute my selenium script from command line, I’m very new using java. Actually, I have been following your tutorials to create my scripts.

I’m using:
Selenium Webdriver Java
Eclipse Kepler
POI libraries

I need to do this because I’m using XStudio Test Management Tool and the first step to create the launcher to execute the selenium script from the tool is to have the commands to execute the script from command line.

Thank you for your time, this website rocks.

Juliow Train Asked on November 7, 2014 in Selenium WebDriver.

Never tried this before, but will look into this.

on November 10, 2014.
Add Comment
1 Answers

Hi julio

As you are using testing , then you must have testsuite XML to run and if you have then simple solution is to run testsuite via testng command line support. Put your testng jar in class path and then run” java org.testng.TestNG testng1.xml “.

For adding testng to class path you can Google how to put jar in classpath

Supporter Answered on November 10, 2014.

hi Kapilag,

Thanks for your answer, I did try something like this, but I’m getting this error. I  did google it and the only explanation is that I have to modify the XML with the package name and the class name but still displaying the same error:

C:\Users\jmoren02\workspace\TestProject\src\Configurator_Tests>java org.testng.TestNG %ProjectPath%\testng.xml
[TestNG] [ERROR]
Cannot find class in classpath: Configurator_Tests.SelectConfigurator_ProductTest

on November 10, 2014.

`which version of testNG are you using ?Can you paste the full stacktrace , what i can see is that testNG is not able to find the class 

on November 10, 2014.

Hi Kapilag, is working now, I have to copy and paste the classpath generated from eclipse that uses to execute the Testng compile server. Thank you.

on November 10, 2014.


on November 10, 2014.

Hi Julio,

I request you to please mention the steps here, so that other people can also refer it or you use the blog section as well from the top menu and paste the link here.

Lakshay Sharma

on November 12, 2014.

Sure Lakshay,

These were my steps to execute a Selenium Webdriver TestNG from Command Line in Windows 7:

1) Download Java JDK and install it. The path should be something like this (C:\Program Files\Java\jdk1.8.0_20)

2) Next step, you need to add this path to Enviroment Variables. Insert the JDK path in variable path, DO NOT DELETE THE CONTENT OF THIS VARIABLE, just add the jdk path by adding  ; at the end and paste the path.(

3)I had a previous configuration of Selenium Webdriver with Eclipse and TestNG by following the tutorials of this website.

4) You need the classpath that is generated by Eclipse to run your scripts. You can get this by debbugin your script and see the properties of the RemoteTestNG.

RE: Execute my Selenium Webdriver scripts in command line

5) Righ click on org.testng.remote.RemoteTestNG and select Properties to copy the classpath

RE: Execute my Selenium Webdriver scripts in command line

6) Open cmd in Windows 7 and follow the steps from this website You already have the correct classpath from step 5.

I hope is clear, let me know if more details are required.

Julio Moreno

on November 12, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.