Skip to main content

Generate Test Case

Sauce AI generates automated test cases directly from plain-English descriptions, eliminating the overhead of manual script authoring. To generate a test, provide your web application URL or select your mobile app from App Management, configure your target browser or device environment, and describe your testing goal.

Sauce AI then interacts directly with your application to run your testing objective, automatically capturing every digital interaction as a structured, sequential test step. Once this automated generation process is complete, you can review the entire test flow, edit individual actions or validations as needed, and immediately save or run the finalized test case.

info

Before getting started, please refer to the Prerequisites.

Step 1: Inside your Sauce Labs account, find Test Authoring from the left-hand navigation menu, expand its available options, and select Test Cases and Suites.

 test case

Step 2: Click Create Test Script in the top-right corner to start a new test generation session. The button is also displayed in the center of the page when no test cases have been created.

 test case

After clicking on the Create Test Script, the test generation setup page opens, where you can choose the type of application you want to test, configure the target testing environment, and write the natural-language prompt describing the test scenario you want Sauce AI to generate.

Select Your Application Type

Choose the type of application you want to test based on your testing requirements.

Application TypeDescriptionSupported Formats
Web ApplicationEnter the complete URL of the web application you want to test. Sauce AI launches a browser session and interacts with your application based on the provided test prompt.URL
Mobile ApplicationSelect your application from the available builds uploaded to App Management. The list displays the latest uploaded application builds available in your Sauce Labs account.Android: APK iOS: IPA, ZIP
 test case

Additional Test Generation Options (Optional)

Before generating your test case, you can customize the test generation environment by clicking the Settings (Cog) icon. This allows you to configure the platform, browser or device settings, network access, and the maximum number of steps Sauce AI can generate.

The following configuration options are available:

Ref.OptionDescription
1Application TypeSelect whether you want to generate a test for a Website or a Mobile application. The available device configuration options are updated based on the selected application type.
2Platform to Generate OnSelect the operating system or mobile platform where Sauce AI will perform the test generation.
3Browser to Generate OnFor web applications, select the browser that Sauce AI will use to interact with your application during test generation.
4Tunnel ProxiesEnable this option if your application is hosted on a private or restricted network that requires a Sauce Connect tunnel to establish secure access during test generation. If your organization enforces tunnel usage, the default tunnel is automatically selected for your test runs.
5Cut Off Test Steps AtDefine the maximum number of steps Sauce AI can generate during the test creation process. The maximum supported value is 200 steps. This helps control the size and complexity of the generated test flow.
note

If you do not modify these settings, Sauce Labs automatically applies the default configuration based on your selected application type. Your most recently used settings are also saved and applied to future test generation sessions.

 test case

Write Your Test Prompt

After selecting your application type and configuring the test generation settings, describe the test scenario you want Sauce AI to automate using a natural-language prompt.

tip

Instead of entering sensitive or reusable values directly in your prompt, you can reference Data Variables using the {{variable_name}} syntax or insert them from the {x} button. For more information, see Data Variables.

You can write prompts in everyday language. For example:

Log in to the application using valid credentials and verify that the dashboard page is displayed successfully.

Sauce AI understands the intent behind your instructions and translates them into automated test steps. However, providing more specific details helps generate more accurate and reliable test flows.

note

If your team already maintains test cases using Gherkin or other behavior-driven development (BDD) formats, you can provide those scenarios directly as prompts.

For example: Given I am on the login page. When I enter valid username and password And I click the Sign In button Then I should be redirected to the dashboard

Clear and specific prompts produce more reliable test flows. Include important details such as the exact UI elements to interact with and the expected outcome of each action.

For additional prompting recommendations, see the Test Authoring Prompting Guide.

 test case

Start Test Generation

After entering your application details and test prompt, click Start Session to begin the test generation process.

Sauce AI launches the selected browser or device environment and interacts with your application based on the instructions provided in your prompt.

 test case

During generation, Sauce AI can perform actions such as:

  • Clicking buttons and links.
  • Entering text into input fields.
  • Performing right-click and double-click actions.
  • Long pressing on mobile devices.
  • Scrolling through application screens.

Each action is executed in real time, and the system captures the details required to build the automated test flow.

Review the Generated Test Flow

After the test generation session is complete, Sauce AI provides the generated test in multiple views to help you review and validate the results before editing, saving, or running the test.

Test Steps View

The Test Steps view displays the generated test flow in a clear, step-by-step format. This allows you to review how Sauce AI interpreted your prompt and generated the test scenario.

The generated test flow includes details such as:

  • The pages or screens visited during the test.
  • The buttons, links, and other UI elements interacted with.
  • The input values entered during the test.
  • The element locators used to identify application components.

Reviewing the generated steps helps you verify that the test accurately reflects the intended user workflow.

tip

If the generated test flow does not match your expected behavior, you can stop the generation, refine your prompt, and try again. During generation, the start prompt button changes into stop while prompt result is being generated.

 test case

Session View

The Session view provides a video recording of the test generation session. This allows you to watch the actions performed by Sauce AI in the browser and visually confirm that the generated workflow matches the expected behavior of your application.

 test case

Code View

The Code view allows you to generate automation scripts from the test case using your preferred programming language and automation framework.

Code generation is an on-demand action. The generated script is created when requested and is not saved as part of the test case. You can regenerate the script at any time using different language and framework combinations.

After generating the script, you can review, copy, or download it for use in your existing test automation projects and CI/CD pipelines.

For detailed instructions, see Generate Test Scripts.

This view helps you convert authored test cases into reusable automation code while maintaining the workflow defined in the generated test.

caution

Known limitations when generating on Safari

Some Test Authoring capabilities are not fully supported when generating tests on Safari.

When using Safari:

  • Session data may not always be completely cleared between generation restarts.

  • Some selector types, including selectors inside Shadow DOM elements, may not be generated correctly.

For the most reliable test generation experience, Sauce Labs recommends using a Chromium-based browser, such as Google Chrome.

Save Your Test Case

After reviewing and confirming the generated test flow, you can save the test case to:

  • Reuse it later
  • Organize it into test suites
  • Schedule executions
  • Run it on demand.

Step 1: After you have reviewed the generated test flow and confirmed that all actions, validations, and expected outcomes align with your testing requirements, click Save Test Case to save your generated test case.

 test case

Step 2: In the Save Test Case dialog, provide the following details before saving your test case:

Ref.FieldDescription
1Test Case NameEnter a meaningful and descriptive name for the test case. A clear name makes it easier to identify, search, and reuse the test case later.
2Add to Test Suite (Optional)Select an existing test suite to organize the test case within a related testing workflow. Leave this field blank if you do not want to associate the test case with a test suite.
3Tags (Optional)Add one or more tags to categorize the test case. Tags help organize, search, and filter test cases based on features, modules, priorities, releases, or other criteria. A test case can have multiple tags. The maximum allowed number of tags per test case is 20.

After providing the required details, click Save to store your test case.

 test case

The saved test case will be available in the Test Cases and Suites page for future execution, modification, and management.

 test case