Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Connect & Get help from 6000+ developers on our Discord community. Ask the CommunityAsk the Community

Automate Tests with AI

Test Companion can convert your manual tests into executable, ready-to-use automation scripts (e.g., Playwright, Cypress, WebdriverIO) with a single click.

It is recommended to use the UI Test Generator agent for this task. You can do this in two ways:

  • From a prompt: Write a natural language instruction for a new automated test.
  • From an existing test: Convert an existing test you already have in your list.

Create Automation from a Prompt

Use this method to create a new automated test from scratch using a simple instruction.

  1. In the Test Companion panel, click the agent dropdown at the bottom and select UI Test Generator.

    Select UI test generator agent from the dropdown

  2. In the chat box, write a clear prompt describing the test you want to create.
    You can also paste your requirements or user story directly into the chat.

    Write a clear prompt describing the test you want to create

  3. Send the message.

Automate an existing test

Use this method to convert a manual test case (that you previously generated or wrote) into an automation script.

Instead of starting from the chat, you start by selecting tests from your list.

  1. In the Test Companions’s Test Management panel, find the manual tests you want to automate.
  2. Click the checkboxes next to its Test ID to select it.

    Select test cases you want to automate

  3. Select the UI Test Generator agent from the agent dropdown.

    Select UI test generator agent from the dropdown

  4. Write your instructions in a clear prompt.
  5. Send the selected tests to the agent.

The AI will read the test case details (title, description, steps), open a browser to try the flow, and then generate the code.

After the agent is finished, two things happen:

  1. A new test script file is added to your project’s codebase.
  2. The Automation Status for that test case is automatically updated from Not Automated to Automated in the management panel.

Get better scripts: Provide good context

The AI builds the script based on the details in your manual test case. For the best results, make sure your test case includes clear information.

Input Description
Test Case Title The AI uses this as the primary goal.
Description A clear summary of what the test validates.
Steps The specific actions the user must perform.
Expected Outcome The result that confirms the test passed.
Application Context Include helper info like the URL, username, or password so the AI can log in.

Example prompt from a manual test case

Prompt: Create an automated test that verifies a registered user can log in with valid credentials and reach the dashboard.

Manual test case details:

  • Test case title: Verify login with valid credentials
  • Description: You log in with a valid username and password and reach the dashboard.
  • Preconditions: User exists with username testuser and password password123.
  • Steps:
    1. Go to https://example.com/login.
    2. Enter username testuser.
    3. Enter password password123.
    4. Click Login.
    5. Verify the dashboard loads (URL contains /dashboard and a visible heading Dashboard).

Generate API tests

This method uses the API Test Generator agent to create new automated API tests. The AI will analyze your prompt, inspect your existing project to understand its framework, and then call the target endpoint to generate a complete test file.

  1. In the Test Companion panel, click the agent dropdown at the bottom and select API Test Generator.

    Select API Test Generator agent from the dropdown

  2. In the chat box, write a clear prompt describing the API you want to test.
  3. Send the message.

The API Test Generator will begin its task. You can see its plan in the chat window. It will:

  1. Analyze your project: It reads files like package.json and existing test configs (e.g., playwright.config.ts) to understand your testing framework and project structure.
  2. Call the API: It makes a live request to the target endpoint to get a real response.
  3. Generate a test plan: It creates a “Discovery Summary” and a plan that includes tests for response status, headers, data schema, error codes, and more.
  4. Write the test file: The AI generates a new test script (e.g., product-listing.spec.ts) in the correct format for your project and adds it to your workspace.

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle