How to execute a script written in Eclipse using command prompt

Hi

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.

queries:
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.

code/Script:—-

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();
driver.get(“http://www.google.com”);
driver.close();
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 Answer(s)
Juliow 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

thanks

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:
"<javaInstallPath>/bin/java.exe"
–classpath "<junitJarPath>;<additionalClassPath>;<javaClientDriverJarPath>;<testRootPath>"
junit.textui.TestRunner <testPath>.<testName>

For JUnitv4:
"<javaInstallPath>/bin/java.exe"
–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.

http://www.xqual.com/documentation/launchers/selenium_java.html

Regards.

on January 9, 2015.
Add Comment

Your Answer

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