Thursday, January 17, 2013

Run Selenium Scripts from CommandLine



Hi everyone.

Some of you would have at least  tried Running selenium through any IDE's Like Eclipse or Netbeans.

Now I am sharing my idea how to run the scripts without using any IDE.
--------------------------------------------------------------------------------------------------------------
Step 1

Make a Folder named "TestLibrary"

Add your Selenium jar file in to that.

eg: C:\TestLibrary\SeleniumServer.jar
-----------------------------

Step 2: 

Create another folder "TestScripts"

Keep the Selenium scripts in this  folder:"TestScripts"

Eg: c:\TestScripts

Let "FirstScript.java" is kept in this folder

c:\TestScript\FirstScript.java

-----------------------------------------
Step 3:

open Cmd prompt

Run>cmd

type the command


javac -cp "c:\TestLibrary\SeleniumServer.jar" "c:\TestScripts\FirstScript.java"

or

javac -classpath "c:\TestLibrary\SeleniumServer.jar" "c:\TestScripts\FirstScript.java"

Now the file will be compiled to a class file named FirstScript.java
----------------------------------------------------

Next Run the script:

java -cp "c:\TestLibrary\SeleniumServer.jar" "c:\TestScripts\FirstScript"

or


java -classpath "c:\TestLibrary\SeleniumServer.jar" "c:\TestScripts\FirstScript"


Note: Start the Selenium server before running if the script is a RC script.

-----------------------------------------------------------------------------------------------------


have a nice tyme..




1 comments: