Skip to content

Learn

Test script: What it is and how to write one

Learn what makes an effective test script, explore practical examples, and understand how test scripts support consistent software testing.

test scripts - what it is and how to write one

TL;DR

  • A test script is a step-by-step set of instructions that explains what to test, which actions to take, what data to use, and what result to expect.
  • Test scripts come in two main types. Manual scripts use plain language for a tester to follow, while automated scripts use code, reusable actions, or testing tools to run checks automatically.
  • A test script differs from a test scenario, test case, and test plan. A test scenario describes what to test, a test case defines the conditions and expected result, a test script explains how to run the test, and a test plan sets the overall testing strategy.
  • A good test script includes a clear test script ID and objective, preconditions, test data, detailed steps, expected results, actual results, and a pass or fail status.
  • To write a reliable test script, define one clear objective, prepare the test environment and data, write specific steps, add an expected result for each step, review the script, and update it when the application changes.
  • Manual test scripts work well for usability testing, exploratory testing, and checks that require human judgment. Automated scripts work best for stable, repetitive, high-volume, and regression tests.
  • Clear test scripts help teams run tests consistently, find defects, confirm requirements, document application behavior, and reduce errors during testing.

A test script tells a human tester or automated testing tool what to check, which steps to follow, and what result to expect.

As Edsger W. Dijkstra wrote, “program testing can be a very effective way to show the presence of bugs, but is hopelessly inadequate for showing their absence.”

Testers need a repeatable way to look for those bugs, and that’s what a test script provides: a clear process and an expected outcome for each check.

This guide explains the types of test scripts; how they differ from test cases, test scenarios, and test plans; and what each script should include. It also covers how to write a test script step by step, with a complete example, practical use cases, best practices, and common mistakes to avoid.

What is a test script?

A test script is a detailed set of instructions that tells a human tester or an automated testing tool exactly how to test a specific part of an application and what result to expect.

It breaks the testing process into a series of steps, with an expected outcome for each one. When the actual result does not match the expected result, the team needs to investigate the difference.

Experienced QA engineers, developers, and automation testers often write test scripts because they understand how the application should work and can define the correct result for each step.

Why use test scripts?

Test scripts give teams a clear, verifiable way to check whether software works as expected. They serve four main purposes:

  1. Bug detection: Test scripts help teams find bugs by comparing actual results with the expected results in the script.
  2. Guidance: They tell testers which steps to take, what input to use, and what result to expect, so tests run consistently regardless of who executes them.
  3. Verifying requirements: Test scripts confirm that the software meets the requirements defined during development.
  4. Documentation: A well-written test script records how the application should work, which helps with onboarding, debugging, and future testing.

What are the types of test scripts?

The two main types of test scripts are manual and automated. Manual scripts give a person written steps to follow, while automated scripts give a testing tool the instructions it needs to run checks. Most teams use both because each works better in different situations.

Manual test scripts are written instructions that guide a tester through a test one step at a time.

1. Manual test scripts

Manual test scripts are written instructions that guide a tester through a test one step at a time. The tester performs each action, enters the specified data, and checks whether the actual result matches the expected result.

For example, a manual login script might ask the tester to:

  1. Open the login page.
  2. Enter a registered email address.
  3. Enter the correct password.
  4. Click the Log in button.
  5. Confirm that the dashboard opens.

Manual test scripts work best when a test requires human judgment, such as usability testing, exploratory testing, or checking usability and visual behavior across devices. They also suit new or frequently changing features that are not stable enough to automate.

Angie Jones, a consulting automation engineer, explains why human testing still matters:

“Automated scripts are checking known paths for expected results. That’s not truly testing. Testers discover the unknown, and this skill is still very much so needed, whether there’s automation or not. Without human intuitive exploration, a team may be blind to their most expensive bugs.”

The trade-off is time. Manual execution is slower and may become inconsistent when testers repeat the same steps across many releases.

Use case: Reviewing a redesigned checkout flow

Problem: Consider an e-commerce team that redesigned its checkout flow and needs to confirm that customers can understand the new steps, which is something automation cannot judge on its own.

Solution: Testers run manual scripts for guest checkout, registered-user checkout, and failed payment scenarios on desktop and mobile devices.

Outcome: In this example, the team reviews 12 checkout paths in one session and finds four usability issues before release.

2. Automated test scripts

Automated test scripts let a testing tool perform actions, compare actual results with expected results, and report whether the test passed or failed. Teams typically automate repetitive checks such as login tests, API tests, and regression tests.

Teams create automated scripts in several ways:

  • Code-based: Written with code using automation frameworks and testing libraries. This approach offers flexibility but requires coding knowledge and ongoing maintenance.
  • Record-and-playback: A tool records a tester’s actions and turns them into reusable steps. This approach is quick to start, but the scripts may break when the interface changes.
  • Keyword-driven: Built from reusable actions such as “open page” or “verify message.” This lowers the coding barrier and reduces repeated work.
  • Model-based or low-code: Tools like Tricentis Tosca build tests from a model of the application instead of requiring teams to write every step as raw code. This can reduce maintenance as the application changes.

Automated scripts run faster once teams create them and can run in continuous integration pipelines after every code change. They still require planning and maintenance, and they do not replace tests that depend on human judgment.

Use case: Reducing regression testing time

Problem: Consider a release team with 120 regression tests that take two testers about eight hours to run manually before every release.

Solution: The team automates 90 stable and repetitive tests, including login, account management, search, and checkout, and runs the suite after every merge.

Outcome: In this example, the automated checks finish in 45 minutes instead of eight hours, allowing testers to investigate failures and explore higher-risk features.

Use manual scripts when a test requires human judgment, the feature changes often, or the team needs to explore unexpected behavior.

When should you use manual or automated test scripts?

Use manual scripts when a test requires human judgment, the feature changes often, or the team needs to explore unexpected behavior.

Use automated scripts when a test is stable, repetitive, or needs to run frequently across several environments. Most teams combine both approaches: automation handles repetitive checks, while manual testing covers usability and exploration.

Test script vs. test case vs. test scenario vs. test plan

A test plan, test scenario, test case, and test script serve different purposes in testing. A test plan defines the overall strategy, a test scenario identifies what to test, a test case defines a specific condition and expected result, and a test script explains how to execute the test.

DocumentPurposeLevel of detailWhen to use it
Test planDefines the overall testing strategy for a project or releaseHigh-level scope, goals, resources, schedule, and risksBefore testing begins
Test scenarioIdentifies a feature, workflow, or user journey to testBroad description of what to verifyWhen planning coverage
Test caseDefines a specific condition, input, and expected resultModerate detail for one behavior or requirementWhen designing an individual test
Test scriptProvides the exact steps or code needed to run a test Detailed actions, data, and expected resultsDuring manual or automated test execution

Strengths and trade-offs

  • Test plan: Gives the team a shared direction, but it does not provide enough detail to run individual tests.
  • Test scenario: Helps teams identify coverage gaps quickly, but it is too broad to execute directly.
  • Test case: Defines exactly what the team needs to verify, but it may not include enough execution detail for every tester or tool.
  • Test script: Makes tests repeatable and consistent, but it takes more time to write and maintain.

How they work together

Together, these testing documents move from broad planning to detailed execution.

how-test-plan-scenarios-scripts-work-together

For an e-commerce checkout flow, the test plan might cover the full checkout release. One test scenario could verify that a customer can complete a purchase.

A related test case could confirm that the customer can pay with a valid card, while the test script would list the exact steps, test data, and expected results for completing that payment.

Teams do not always store all four as separate documents. Some test management tools combine the test case and test script in one record. What matters is that the team clearly defines what to test and how to execute it.

What are the components of a test script?

A test script includes the information needed to identify, prepare, execute, and evaluate a test. The exact format may vary, but manual and automated test scripts usually include the same core components.

test script components

1. Test script ID and title

This gives the script a unique identity and states what it’s testing. It includes:

  • Test script ID: A unique identifier used for tracking and reporting, such as `LOGIN-001`.
  • Test script title: A descriptive name that identifies the test at a glance. For example, “Verify successful login with valid credentials.”

2. Objective

The objective states exactly what the script should confirm. It should focus on one specific behavior or requirement so the test does not become too broad.

For example, “Confirm that a registered user can log in with valid credentials” gives the script a clearer purpose than “Test the login page.”

3. Preconditions

Preconditions are the conditions that must be true before the test starts, such as the user having a registered account or the test environment being available.

They may also include the required user role, application state, browser, device, database record, or completed setup step. Clear preconditions help teams separate setup problems from actual product defects.

4. Test data

Test data includes the values, records, files, or parameters needed to execute the test. Examples include usernames, passwords, product IDs, dates, payment details, uploaded files, or API payloads.

The script should state the exact data to use or explain where the tester can get it. Teams can also use both valid and invalid data to confirm how the application handles successful actions and errors.

5. Instructions and actions

This is the step-by-step part of the script. It describes how the tester or testing tool should interact with the software, like opening a page, entering a value, selecting an option, or clicking a button.

Write the actions in the order they should happen, and keep each step focused on one clear action. Another tester should be able to follow the instructions without relying on assumptions or additional help.

6. Expected results

The expected result shows how the application should respond after each action. It could describe a page loading, a message appearing, a status changing, data being saved, or an error being displayed.

Expected results should be specific enough to support a clear pass or fail decision. For example, “The dashboard loads and displays the user’s name” is more useful than “The login works.”

7. Actual results

The actual result records what happened when the test ran. During manual testing, the tester enters the observed result after completing each step.

During automated testing, the test runner captures the outcome through assertions, logs, screenshots, videos, or reports. Recording the actual result helps teams understand what failed and compare it with the expected behavior.

8. Pass/fail status

The status shows whether the application behaved as expected. Mark the test as passed when the actual result matches the expected result and failed when it does not.

Teams may also use statuses such as blocked, skipped, or not run when they cannot complete the test or have not executed it yet.

How do you write a test script step by step?

Writing an effective test script starts with a clear objective and ends with a script that another tester can follow without extra help.

A good test script tells the tester what to do, what data to use, and what result to expect.

Step 1: Define a clear objective

Decide which part of the application you want to test and what the test should confirm; for example, “Confirm that a registered user can log in with valid credentials.” A specific objective keeps the script focused and prevents it from covering unrelated behaviors.

Step 2: Document preconditions and prepare test data

List everything that must be in place before the test starts. This may include an active user account, an available test environment, or a specific application state. Also provide the usernames, passwords, files, product IDs, or other data needed to run the test.

Step 3: Write detailed test steps

List the actions in the order the tester or testing tool should perform them. Keep each step focused on one action and use clear instructions.

For example:

  1. Open the login page.
  2. Enter a registered email address.
  3. Enter the correct password.
  4. Click the Log in button.

Step 4: Specify expected results

State what the application should do after each action. The expected result should be specific enough to determine whether the step passed or failed. For example, after the tester clicks Log In, the dashboard should open and display the user’s account information.

Step 5: Review and maintain the script

Use plain language, give the script a descriptive title, and ask another team member to review it before execution. Update the script whenever the requirements, interface, test data, or application behavior changes.

What does a test script example look like?

A test script shows how every part of a test works together, including the objective, preconditions, test data, execution steps, and expected results. Anyone should be able to follow it and run the same test without asking the person who wrote it for help.

The example below tests whether a registered user can log in with valid credentials.

Test script details

FieldValue
Test script IDLOGIN-001
Test script title Verify successful login with valid credentials
ObjectiveConfirm that a registered user can log in with the correct email and password and access the dashboard
PreconditionsThe user has an active account, is logged out, and can access the test environment
Test dataEmail:
user@example.com
, Password:
ValidPassword123

Steps and expected results

StepActionExpected result
1Enter
user@example.com
in the email field
The login page loads with the email field, password field, and Log In button visible
2Enter the email addressThe field accepts and displays the email address
3Enter
ValidPassword123
in the password field
The field accepts the password and displays it as masked characters
4Click the Log In buttonThe application accepts the credentials and redirects the user without displaying an error
5Check the page after the redirectThe dashboard loads, and the URL includes
/dashboard

Actual result: The application accepted the credentials and opened the user’s dashboard. The URL changed to `/dashboard`.

Status: Pass

This script gives the tester a clear objective, the required setup, the data to enter, and a specific expected result for every action. If the application behaves differently at any step, the tester can mark the script as failed and record the issue.

The same test can also be written as an automated script. Each manual action maps to an automated command: opening the login page, entering the email and password, clicking the button, and checking the dashboard URL.

Both versions test the same behavior, but one gives instructions to a person while the other gives instructions to a testing tool.

What common mistakes should you avoid when writing test scripts?

The most common test script mistakes include vague steps, missing expected results, fixed test data, dependent scripts, poor maintenance, and unclear objectives. These mistakes make tests harder to execute, trust, and update.

1. Writing vague or unclear steps

A step such as “log in” assumes the tester already knows which page to open, which details to enter, and which button to click. Write each action clearly enough for another tester to follow without additional instructions.

2. Leaving out expected results

Without an expected result, the tester has nothing to compare the application’s actual behavior against. Add a clear expected outcome to every step so the tester can determine whether it passed or failed.

3. Depending on fixed test data

A script may stop working when it depends on one account, record ID, URL, date, or environment-specific value that later changes. Keep test data separate from the execution steps where possible so testers can replace it without rewriting the script.

When one script only works after another script has run successfully, one failure can trigger several unrelated failures.

4. Making scripts depend on one another

When one script only works after another script has run successfully, one failure can trigger several unrelated failures. Give each script the setup and data it needs so teams can run it independently.

5. Failing to update scripts after application changes

A renamed button, updated workflow, or changed validation rule can make an existing script inaccurate. Review and update the affected scripts whenever the application changes to prevent false failures and outdated instructions.

6. Starting without a clear objective

A script without a specific objective may test too many unrelated behaviors or miss the main requirement. Start with one sentence that states exactly what the script should confirm.

What are the best practices for writing test scripts?

The best practices for writing test scripts are using version control, keeping scripts updated, prioritizing them by risk, and collaborating across the team. These practices help teams keep their test scripts accurate and easier to maintain as the application changes.

1. Use version control

Store your test scripts, especially automated ones, in a version control system like Git, the same way you store application code. This lets you track changes over time, see who updates a script and why, and restore a previous version if something breaks.

2. Keep test scripts up to date

Update your test scripts whenever the application changes, even for small changes like a renamed button or a different page flow. An outdated script can report a failure that has nothing to do with an actual bug, which wastes time and reduces trust in the test suite.

3. Prioritize test scripts based on risk

Focus your scripts on features that are likely to fail or would have a serious business or user impact if they did, such as checkout, login, or payment processing. Not every feature needs the same level of coverage, so prioritize the parts of the application that matter most.

4. Collaborate with other team members

Work with developers, business analysts, and other testers when writing and reviewing test scripts.

A second set of eyes can catch unclear steps, missing preconditions, and gaps in coverage that the original writer might miss. It also keeps the script useful to the whole team, not just its author.

Conclusion

A test script is only useful when another tester or testing tool can follow it without confusion. Keep each script focused, make the expected results clear, and update it whenever the application changes.

As your test suite grows, maintaining scripts can become as challenging as creating them. Tricentis helps teams automate and manage testing across complex applications while reducing ongoing maintenance.

Explore Tricentis Tosca to see how your team can build and maintain automated tests more efficiently.

Author:

Chosen Vincent

Guest contributor

Date: Aug. 20, 2026

FAQs

What is a test script?

A test script is a step-by-step set of instructions that tells a human tester or an automated testing tool how to test a specific part of an application and what result to expect. It includes the actions to perform, the data to use, and the expected outcome.

How do you write test scripts?

Start by defining one clear objective for the test. Then document the preconditions and test data, write each action in order, and add the expected result for every step. Review the script before using it and update it whenever the application changes.

What is the difference between a test case and a test script?

A test case defines what to test, including the objective, conditions, inputs, and expected result. A test script explains how to execute the test by providing the exact actions a tester or testing tool should perform.

What is a test script in UAT?

In user acceptance testing (UAT), a test script guides business users or stakeholders through real-world workflows to confirm that the application meets their requirements before release.

UAT scripts usually focus on complete business processes, such as placing an order or approving an invoice, rather than testing one isolated function.

Who writes test scripts?

QA engineers, manual testers, and automation engineers commonly write test scripts. Developers may write automated scripts, while business analysts, product owners, and business users may help create or review scripts for UAT.

Is a test script the same as a test plan?

No. A test plan defines the overall scope, objectives, resources, approach, schedule, and responsibilities for a testing project. A test script provides the detailed instructions for executing a specific test covered by that plan.

What tools are used to run automated test scripts?

Teams use tools such as Tricentis Tosca, Cypress, Playwright, and Selenium to automate tests. Cypress, Playwright, and Selenium execute code-based scripts, while Tricentis Tosca supports model-based test automation that reduces the amount of code teams need to write and maintain.

You may also be interested in...