Selenium 2 WebDriver Advanced
  • Preface
  • 1. API Testing Using Selenium WebDriver
    • 1.1 Code Snippet for API testing
    • 1.2 SoapUI
      • 1.2.1 Add selenium jars to soapUI
      • 1.2.2 Run selenium tests
      • 1.2.3 Data Driven Testing using SoapUI
  • 2. Advanced Profiles for Browsers
    • 2.1 Profile for Firefox Browser
    • 2.2 Profile for Chrome Browser
    • 2.3 Profile for IE Browser
    • 2.4 Profile for Safari Browser
    • 2.5 Profile for Opera Browser
  • 3. TestNG
    • 3.1 Sample TestNG class
    • 3.2 Parallel execution
    • 3.3 Execution of tests from batch file
  • 4. ExtentReports
    • 4.1 Basics
    • 4.2 Sample Extent Reports
  • 5. Advanced tricks
    • 5.1 Keystroke handling
    • 5.2 Screenshot capture
    • 5.3 Get HTML Source of WebElement
Powered by GitBook
On this page

Was this helpful?

  1. 3. TestNG

3.3 Execution of tests from batch file

We will see how does one make use of TestNG to Execution of tests from batch file.

First one needs to set the JAVA_HOME in the system environment variables so that we can run the tests using the batch file.

Set the classpath of java so that the compilation can be done using command prompt.

Save the below batch code in a new file and save it as "RunBatchtests.cmd"

set projectLocation=C:\Saikiran\TestNGProject
cd %projectLocation%
set classpath=%projectLocation%\bin;%projectLocation%\lib\*;C:\Saikiran\Libraries\selenium-java-3.0.1\*;C:\Saikiran\Libraries\selenium-java-3.0.1\lib\*;C:\Saikiran\Libraries\extentreports-java-2.41\extentreports-java-2.41.2\*;C:\Saikiran\Libraries\extentreports-java-2.41\extentreports-java-2.41.2\lib\*;C:\Saikiran\Libraries\poi\*;

javac -cp %classpath% org.testng.TestNG %projectLocation%\smoke.xml
pause

After saving the file open the batch file to execute the tests from desired location.

It is a good practise to store the libraries inside the project so that we do not need to explicitly mention the libraries location instead specifying only the library folder name "lib".

The same batch can also be passed in Jenkins jobs to execute tests from a continuous integration server.

Previous3.2 Parallel executionNext4. ExtentReports

Last updated 5 years ago

Was this helpful?