Purpose: Running Selenium Script from console/command prompt using .class instead of .java file with out JDK - TestNG
Some times we need to run our automation script at client box to demonstrate our ability to automate but we don't want to share our code with out JDK ( required - JRE). We can achieve this by following below steps. With this we can run the script from .class instead of .java file.
We can achieve this using both JUnit and TestNG. In this example we are working with TestNG
Here my example is GoogleConsole.java
Step 1: Prepare required scrip using any IDE and compile
Step 2: Open command prompt in another system and check whether JRE is available
Step 3: Prepare testing.xml file as follows
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Google">
<test name="GoogleConsloe">
<classes>
<class name="GoogleConsole"/>
</classes>
</test>
</suite>
Step 3: Copy selenium standalone server, TestNG.jar, .class and testing.xml files to a folder(D:\Google\)
Step 4: Open command prompt and change to D:\Google\
Step 5: Set path using the following command
set classpath=%classpath%;D:\Google\selenium-server-standalone-2.39.0.jar;D:\Google\testng-6.8.jar;.;
*Note: update the paths of the .jar files and .class file according to your path.
Step 6: Run the class file using the following command
java org.testng.TestNG java org.testng.TestNG testng.xml
Now you can see the bowser will open and perform the required operation without code and eclipse
Some times we need to run our automation script at client box to demonstrate our ability to automate but we don't want to share our code with out JDK ( required - JRE). We can achieve this by following below steps. With this we can run the script from .class instead of .java file.
We can achieve this using both JUnit and TestNG. In this example we are working with TestNG
Here my example is GoogleConsole.java
Step 1: Prepare required scrip using any IDE and compile
Step 2: Open command prompt in another system and check whether JRE is available
Step 3: Prepare testing.xml file as follows
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Google">
<test name="GoogleConsloe">
<classes>
<class name="GoogleConsole"/>
</classes>
</test>
</suite>
Step 3: Copy selenium standalone server, TestNG.jar, .class and testing.xml files to a folder(D:\Google\)
Step 4: Open command prompt and change to D:\Google\
Step 5: Set path using the following command
set classpath=%classpath%;D:\Google\selenium-server-standalone-2.39.0.jar;D:\Google\testng-6.8.jar;.;
*Note: update the paths of the .jar files and .class file according to your path.
Step 6: Run the class file using the following command
java org.testng.TestNG java org.testng.TestNG testng.xml
Now you can see the bowser will open and perform the required operation without code and eclipse