What Is Test Scripting Language?


Scott Campbell

What Is Test Scripting Language?

Test Scripting Language (TSL) is a scripting language used in the field of software testing. It allows testers to write scripts to automate the testing process, making it more efficient and reliable. TSL is commonly used with test automation tools like QuickTest Professional (QTP) or Unified Functional Testing (UFT).

TSL Features

TSL comes with a range of features that make it a powerful tool for automated testing:

  • Simple Syntax: TSL has a simple syntax that is easy to learn and understand. This makes it accessible to both experienced developers and beginners.
  • Record and Playback: TSL allows testers to record their actions during manual testing and then play them back as automated tests.

    This saves time and effort in writing scripts from scratch.

  • Data-Driven Testing: TSL supports data-driven testing, where test cases are executed using different sets of input data. This helps in testing the application’s behavior under various scenarios.
  • Error Handling: TSL provides built-in error handling mechanisms, allowing testers to handle exceptions and errors gracefully during test execution.
  • Integration with External Tools: TSL can be easily integrated with external tools like databases, Excel sheets, or other applications for data retrieval or manipulation during test execution.

TSL Syntax

TSL follows a syntax similar to other scripting languages. Here are some key elements of TSL syntax:

  • Variables: Variables in TSL are declared using the keyword Dim. For example, Dim x declares a variable named “x”.
  • Comments: TSL supports single-line comments starting with the symbol '.

    For example, ' This is a comment.

  • Control Structures: TSL supports control structures like If-Then-Else, For-Next, and Select Case. These structures help in implementing conditional and looping logic in scripts.
  • Functions: TSL provides built-in functions for various operations like string manipulation, date handling, file handling, etc. These functions can be used to perform specific tasks within the scripts.

TSL Examples

To give you a better understanding of TSL, here are a few examples:

Example 1: Simple Script

This script opens a web page and verifies the page title:

' Open the web page
SystemUtil.Run "iexplore.exe", "https://www.example.com"

' Verify the page title
If Browser("title:=Example").Page("title:=Example").Exist(10) Then
    Print "Page title is correct"
    Print "Page title is incorrect"
End If

Example 2: Data-Driven Testing

This script performs data-driven testing by reading test data from an Excel sheet:

' Read test data from Excel sheet
Set xlApp = CreateObject("Excel.Application")
Set xlWorkbook = xlApp.Workbooks.Open("C:\TestData.xlsx")
Set xlSheet = xlWorkbook.Worksheets("TestCases")

' Iterate through each row and execute the test case
For i = 2 To xlSheet.UsedRange.Rows.Count
    ' Get the test data from Excel
    input1 = xlSheet.Cells(i, 1).Value
    input2 = xlSheet.Cells(i, 2).Value
    ' Perform the test using the input data
    result = PerformTest(input1, input2)
    ' Write the result back to Excel
    xlSheet.Cells(i, 3).Value = result

' Close the Excel sheet

' Clean up objects
Set xlSheet = Nothing
Set xlWorkbook = Nothing
Set xlApp = Nothing

Function PerformTest(input1, input2)
    ' Implementation of test logic goes here
    ' Return the result of the test case
End Function

These examples demonstrate how TSL can be used to automate different types of tests and interact with external tools or applications.


Test Scripting Language (TSL) is a powerful scripting language used in software testing for automating the testing process. It offers features like record and playback, data-driven testing, error handling, and integration with external tools. With its simple syntax and flexibility, TSL enables testers to write efficient and reliable automated tests.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy