RE: How to execute a script written in Eclipse using command prompt


can anyone please guide me with steps on above query.
Basically i want to execute the below code written in eclipse kepler ( language used: JAVA) using command prompt.

1> is it possible in first place? please mention the steps or a valuable reference link.
2> if not, can you please suggest how to do it, if there are any dependencies.

my priority at present is point 1.


package basics;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class openBrowser {
public static WebDriver driver;
public static void main(String[] args) {
driver = new FirefoxDriver();
System.out.println(“google site opened and firefox closed”);


Thanks in advance

qaparesh Default Asked on January 6, 2015 in Selenium WebDriver.
Add Comment
1 Answers
Train Answered on January 6, 2015.

Thank Juliow

but the post is with use of TestNG.

i would like to know if its possible to run the script without using any external tools.

just compiling and executing the .java file generated from eclipse in cmd


on January 7, 2015.

Yes you can, but you have to download Selenium standalone server and the Junit file that you want to use and execute the following command line:

For JUnitv3:
–classpath "<junitJarPath>;<additionalClassPath>;<javaClientDriverJarPath>;<testRootPath>"
junit.textui.TestRunner <testPath>.<testName>

For JUnitv4:
–classpath "<junitJarPath>;<additionalClassPath>;<javaClientDriverJarPath>;<testRootPath>"
org.junit.runner.JUnitCore <testPath>.<testName>

You can get the complete Class Path from Eclipse just like I explained in my previous post, that is the most important step. You can get more information from this page.


on January 9, 2015.
Add Comment

Your Answer

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