Blog/Quality Assurance

Test Script Examples and Templates (Manual + Automated)

Software engineer writing code on laptop with code visible on two desktop screens in the back

Summarize with:

Test scripts are vital for verifying software functionality. They provide predefined steps for testing applications. In this article, you’ll learn what test scripts are and how you can write them effectively. We also share an example to help you better understand the steps to writing an effective test script. Let’s get started.

What are test scripts?

Test scripts, made up of instructions and code, automate the testing process for software applications. Their primary purpose is to run test cases on a software application, validating its functionality and ensuring it meets specified requirements. They act as a recipe, guiding testers through steps from preconditions and test data inputs to expected outcomes.

A well-crafted complete test script includes detailed actions, necessary test data, and expected results, ensuring comprehensive coverage of the functionality being tested. Following these scripts allows testers to systematically verify the application’s behavior.

Test scripts are pivotal in the software testing process, validating system functionality and guiding testers. This structured approach ensures no steps are missed and all aspects of the application are thoroughly tested. Without test scripts, the process can become chaotic and inconsistent, allowing potential bugs to slip through.

Test scripts offer a valuable reference for future testing, easily reusable and adaptable as software evolves, making them indispensable for QA engineers. Whether in manual testing or automated testing environments, understanding and using test scripts is crucial for comprehensive and effective software testing.

TL;DR

30-second summary

  • A test script is a step-by-step set of instructions that tells a tester (or a tool) exactly what to do to verify a specific piece of software behavior.
  • Manual test scripts are written for a human to follow. Automated test scripts are written in code for a testing tool to execute.
  • Every test script needs the same core parts: an ID, a precondition, the steps, the expected result, and the actual result.
  • Downloadable manual and automated templates are below.
  • AI tools can now draft a first version of a test script, though it still needs a human to verify it against real behavior.

Types of test scripts

In software testing, test scripts come in two main flavors—manual and automated. Each type has its unique characteristics and applications, and understanding when to use each can greatly enhance your testing efforts.

Manual test scripts—more commonly called test cases—are written and executed by human testers in a manual testing environment. These scripts do not require any programming skills, making them accessible to teams with diverse expertise levels. Manual testing is particularly valuable in scenarios that require human intuition and creativity, such as exploratory testing, usability testing, and ad-hoc testing. However, manual testing can be time-consuming and prone to human error, especially for repetitive tasks.

Automated test scripts are created using a programming language. They are then executed with the help of test automation tools. These scripts can be run repeatedly with high accuracy and efficiency, making them ideal for regression testing and performance testing. An automated test script leverages automation testing frameworks to verify outcomes, reducing the time and effort required for repetitive testing tasks.

The decision to use manual or automated testing is influenced by project requirements and complexity. Additionally, available resources play a significant role in this choice.

How to write test scripts

Several methods exist for writing test scripts, each with its advantages and applications. The primary methods include record/playback, keyword/data-driven scripting, and writing a test script using programming languages. Each approach caters to different expertise levels and project requirements.

Record/playback method

The record/playback method is favored by beginners or those seeking a quick way to create test scripts. This approach records user actions, automatically capturing interactions. 

Once recorded, these scripts can be replayed to execute the same actions, making them ideal for regression testing. Although this method requires minimal coding, adjustments may be needed to rectify issues during automated recordings. VBScript is commonly used for writing these scripts.

Keyword/data-driven scripting

Keyword/data-driven scripting enables testers to define tests using keywords and test data, separating logic from data. This approach enhances test management and facilitates collaboration between testers and developers. Testers can create scripts with minimal programming knowledge, focusing on keywords while developers handle the coding.

This method is particularly useful in environments where test logic remains constant but test data changes frequently. Relying on development resources for new functionality testing helps ensure scripts remain relevant and up to date.

Writing code using programming languages

Writing test scripts in programming languages offers the highest flexibility and control, suitable for complex scenarios or in-depth customization. Common languages include Python, Ruby, Perl, Java, and VBScript.

Programming languages enable testers to create more complex and tailored scripts than recorded methods alone. Test scripts do not need to be written in the same language as the application, allowing testers to choose the best tool for the job, regardless of the underlying code base.

Example of a test script 

To bring the concepts to life, let’s walk through an example of a test script that validates the login functionality of a web application.

1. Test script details

  • Test Case ID: TC001-Login
  • Test Title: Verify user login with valid credentials
  • Test Type: Functional
  • Priority: High
  • Tested By: [Name of Tester]
  • Date: [Date of Execution]

2. Prerequisites

  • The user must have a valid registered account (username and password).
  • The application must be accessible via a web browser.
  • Internet connection must be available.

3. Test steps

Step No. Action Expected Result
1 Open the web browser and navigate to the login page (e.g., https://example.com/login). The login page should load successfully.
2 Enter a valid username (e.g., user@example.com) in the username field. The username is displayed in the input field.
3 Enter a valid password (e.g., Password123!) in the password field. The password is masked and displayed as dots (••••••).
4 Click on the Login button. The user is redirected to the home/dashboard page.
5 Verify that the user's name or welcome message (e.g., "Welcome, John!") is displayed on the dashboard. The user should see a personalized greeting or profile name on the dashboard.

4. Test data

Field Input Data
Username user@example.com
Password Password123!

5. Expected result

  • The user is successfully logged into the system and redirected to the home/dashboard page.
  • The user sees their name or a personalized message (like "Welcome, John!") on the page.

6. Actual result

Step No. Actual Result Status (Pass/Fail) Comments
1 Login page loaded successfully. Pass -
2 Username input was accepted and displayed correctly. Pass -
3 Password input was masked and displayed as dots. Pass -
4 User redirected to the dashboard successfully. Pass -
5 Personalized message "Welcome, John!" displayed on the page. Pass -

7. Postconditions

  • The user remains logged in until they log out or close the browser session.
  • The user session should persist as per session timeout rules.

8. Additional notes

  • If the login fails, an error message like "Invalid username or password" should be displayed.
  • Check for edge cases, such as incorrect passwords, blank fields, and SQL injection attempts.

This is a simple test script, but it can be expanded to include edge cases, negative test scenarios, or automation steps if required.

The same script, automated

Here's that exact login check written as an automated script (Selenium, Java), so you can see the manual and automated versions side by side:

@Test
public void verifyLoginWithValidCredentials() {
    driver.get("https://example.com/login");
    driver.findElement(By.id("email")).sendKeys("user@example.com");
    driver.findElement(By.id("password")).sendKeys("Password123!");
    driver.findElement(By.id("login-button")).click();
 
    WebElement dashboardHeader = driver.findElement(By.id("dashboard-username"));
    Assert.assertTrue(dashboardHeader.isDisplayed());
    Assert.assertEquals(dashboardHeader.getText(), "Welcome, John!");
}

Writing automated test scripts

Creating an automated test script is less about the code itself and more about the process around it. Six steps take you from idea to a script that actually runs reliably:

1. Define your testing goals

Identify the features, functions, and performance aspects that need to be tested before writing anything. This gives every script a clear purpose and keeps automation efforts aligned with what actually matters for coverage.

2. Choose the right automation tool

Popular options like Selenium, Cypress, and TestCafe each suit different needs. Weigh compatibility with your application, ease of use, and community support, and run a small proof-of-concept with a couple of candidates before committing.

3. Plan your test cases

Write detailed test cases based on requirements, including specific inputs, expected results, and conditions, before converting anything to code. Prioritize which cases are worth automating first based on the return they'll deliver.

4. Set up your testing environment

The environment should mirror production as closely as possible so results reflect real-world conditions. Configure the tools and dependencies you need up front, rather than discovering gaps mid-script.

5. Write the test script

Use clean, modular code with comments explaining intent, and build in error handling so a single unexpected state doesn't crash the whole run. Modular scripts are easier to reuse and maintain as the application changes.

6. Run the test script

Execute it with your chosen tool and monitor for errors or failures as it runs. Afterward, review the results to catch issues and identify what to adjust before the next run.

Two challenges worth planning for

  • Flaky tests. Often caused by timing issues and dynamic UI elements. Wait commands and mocking external dependencies stabilize results so failures reflect real bugs, not test noise.
  • Maintenance overhead. Scripts drift out of sync as the application evolves. A modular structure and regular code reviews keep updates contained to the parts that actually changed.

Creating effective test scripts

Man sitting at desk with laptop tapping on mobile phone

Creating effective test scripts is both an art and a science. Clear and detailed test scripts guide inexperienced testers and ensure thorough testing. Structuring scripts to be executable by others ensures continuity and consistency.

Clear and descriptive names for test functions enhance understanding and reduce maintenance time. Tests should focus on a single scenario to simplify debugging and improve reliability.

Standardizing the format of test scripts using templates makes the process more efficient and reduces errors. Templates ensure all necessary components are included, promoting consistency and effective communication.

Regular test script maintenance and updates are crucial to keep test scripts effective. Implementing version control helps track changes and improve collaboration, ensuring scripts remain relevant as the software evolves.

When should you use test scripts

Test scripts enhance efficiency, accuracy, and reliability, making them essential for comprehensive software testing. They are particularly useful for large, complex software products, preventing oversight of test steps for each component.

Automated test scripts save time by validating the entire product’s functionality after bug fixes or new features, making them ideal for regression testing. In dynamic environments, test scripts help maintain consistency and accuracy as software changes, allowing teams to test automatically.

Test scripts are effective for performance and load testing, handling large volumes of data accurately. Leveraging test scripts allows testers to execute repetitive tasks efficiently, ensuring thorough and reliable testing.

What are test script templates?

A test script template is a reusable, formatted document that includes essential information for creating practical test scripts. It outlines the test case name, objective, environment, expected result, and additional details. Standardized templates save time, reduce errors, promote consistent script creation, and foster effective communication.

Test scripts, used alongside test cases and a test scenario, allow teams to leverage varying test documentation strategies according to their skill levels. This flexibility ensures all team members, regardless of expertise, can contribute effectively to the testing process and test scenarios.

Skip the blank page: download our free templates below.

Free manual test script template — spreadsheet format, covers ID, precondition, steps, expected result, actual result, and status.

Free automated test script template — starter structure for Selenium/Java, with comments marking where to plug in your own locators and assertions.

Let’s look at an example of a test script template:

1. General information

Field Description
Test Case ID Unique identifier for the test script (e.g., TC001-Login)
Test Title A brief, descriptive title for the test (e.g., Verify Login with Valid Credentials)
Module/Feature The module or feature being tested (e.g., Login Page, Profile Page, Payment Gateway)
Test Type Functional, UI, Integration, Security, etc.
Priority High, Medium, or Low (based on the impact of failure)
Tested By The name of the tester executing the test
Test Date The date when the test is executed
Version The version of the software being tested

2. Prerequisites / pre-conditions

  • List all necessary preconditions for the test (e.g., user must have an active account, network connection must be available, browser cache cleared, etc.).
  • Mention if any dependencies (like environment setup) are required before starting the test.

3. Test steps

Step No. Action/Description Expected Result
1 Clearly describe the action to be performed (e.g., "Open the web browser and navigate to https://example.com/login"). State what should happen as a result of the action (e.g., "Login page should be displayed").
2 Input the username in the username field. The input should be displayed in the field.
3 Input the password in the password field. The input should be displayed as masked dots (••••••).
4 Click the Login button. The user should be redirected to the dashboard.
5 Verify the welcome message is displayed on the page. The message "Welcome, [username]" should appear on the dashboard.

4. Test data

Field Input Data Type
Username user@example.com Valid data
Password Password123! Valid data
Invalid Username invalid_user@example.com Invalid data
Invalid Password WrongPassword! Invalid data

5. Expected result

  • Clearly state the expected end result (e.g., "User should be successfully logged in and see the dashboard page with their username displayed.").
  • Include any changes in the application state (e.g., "User session should persist until the user logs out or the session expires.")

6. Actual result

Step No. Actual Result Status (Pass/Fail) Comments
1 Login page loaded successfully. Pass -
2 Username input was accepted. Pass -
3 Password input was displayed as dots. Pass -
4 User redirected to the dashboard. Pass -
5 "Welcome, John!" displayed on the page. Pass -

7. Postconditions

  • State what conditions must be met after the test has run (e.g., "User should remain logged in until session timeout or manual logout.").
  • Specify any necessary system states (like cookies or cache updates) that should persist.

8. Pass/Fail criteria

  • If all steps pass, the test case is marked as Pass.
  • If any step fails, the test case is marked as Fail, and the issue is logged with a description of the failure, screenshots, or logs if applicable.

9. Notes / additional information

  • Record any observations, suggestions, or notes about the test execution.
  • Mention any known defects, blockers, or issues that occurred during testing.

Adopting test script templates streamlines testing efforts, ensuring all necessary components are included in each script and maintaining a consistent and thorough testing process.

Generating test scripts with AI

AI tools can now turn a user story or a plain-language description of a feature into a first-draft test script in seconds, for both manual and automated formats. That's a real time-saver on repetitive, well-defined flows like login, checkout, or form validation.

It's still a first draft, not a finished script. AI-generated steps need a human to check them against how the application actually behaves, since the tool has no way to know about edge cases, recent changes, or the quirks specific to your product. TestDevLab's AI-augmented testing services combine AI-assisted script generation with ISTQB-certified engineers who verify and maintain those scripts, so speed doesn't come at the cost of accuracy.

What are the benefits of using test scripts?

Man typing on laptop

Test scripts improve efficiency by minimizing time spent on repetitive tasks and ensure consistency and accuracy in validating software functionality. Writing test script code in programming languages offers flexibility and enables complex scenarios.

Essentially, test scripts are useful for:

  • Consistency. Ensures all testers follow the same structure.
  • Reusability. Can be reused for multiple test cases, saving time.
  • Clarity. Clearly defines steps, expected results, and test data.
  • Traceability. Makes it easier to track defects back to test steps.

Well-designed test scripts are a powerful tool for QA engineers, enhancing overall testing processes. Leveraging them allows teams to achieve more reliable and thorough software testing, leading to higher-quality software products.

Conclusion

Test scripts are an indispensable tool in the software testing process, providing a structured and efficient approach to validating software functionality and ensuring quality. They streamline the testing process, reduce human error, and improve the consistency of testing outcomes. Whether you’re using manual or automated scripts, the structure and clarity of your test scripts can make or break the efficiency of your testing efforts. By leveraging test script templates, teams can maintain consistency and save valuable time.

FAQ

Most common questions

What is a test script in software testing?

A test script is a set of instructions, written in plain language or code, that guides a tester through validating a specific piece of software functionality. It defines the preconditions, the steps to perform, the test data to use, and the expected result, so anyone running it gets consistent, repeatable results.

What's the difference between a test script and a test case?

A test case describes what to test and the expected outcome, usually in a human-readable format. A test script is the executable version, either a manual step-by-step document or automated code, that actually carries out the test case. Test cases define the "what," test scripts define the "how."

What are the main types of test scripts?

Test scripts fall into two categories: manual and automated. Manual test scripts, often called test cases, are executed by a human tester and require no coding. Automated test scripts are written in a programming language and run by a testing tool, making them a better fit for repetitive work like regression and performance testing.

How do you create a test script?

Start by defining the test objective and preconditions, then list the exact steps to perform along with the test data and expected results for each step. For automated scripts, choose a testing framework that fits your application (like Selenium for web, Appium for mobile), then write and modularize the code so it's easy to maintain as the application changes.

What should a good test script template include?

A solid template covers general information (test ID, title, module, priority), prerequisites, numbered test steps with expected results, test data, overall expected and actual results, postconditions, and pass/fail criteria. Standardizing this structure keeps scripts consistent across a team and easier to maintain over time.

Stop maintaining test scripts by hand

Free your team from repetitive script upkeep. Our test automation services help you build scalable, reliable test coverage that grows with your product.

Summarize with:

QA engineer having a video call with 5-start rating graphic displayed above

Save your team from late-night firefighting

Stop scrambling for fixes. Prevent unexpected bugs and keep your releases smooth with our comprehensive QA services.

Explore our services