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

Convert your manual test cases into executable Playwright, Cypress, or Selenium scripts with a single prompt.

Test Companion generates complete automation scripts with proper selectors, wait strategies, assertions, and page object patterns. It matches the output to your project’s existing framework and conventions.

How it works

When you ask Test Companion to automate a test, it:

  • Reads the test case details (name, steps, expected results, preconditions).
  • Opens a browser to explore the target URL, if needed, to capture UI elements and their selectors.
  • Generates a complete test script in your chosen framework.
  • Creates the file in your workspace, following your project’s folder structure and naming conventions.

Create an automated test from a prompt

Use this method when you want a new automated test and can describe it in plain language.

  1. Open the Test Companion panel in the IDE.
  2. In the chat box, describe the test you want to automate. Include the URL, the user flow, and any credentials or test data needed.

    Provide context before you generate test cases using file attachments, @ references, and rules

  3. Press Enter to send.

Test Companion inspects your project to detect the installed testing framework, then generates a complete test script file in your workspace.

Example prompt

Create a Playwright test that verifies a user can log in with valid credentials at https://example.com/login.
Use username `testuser` and password `password123`. After login, assert that the URL contains `/dashboard`
and a heading with the text `Dashboard` is visible.

Automate an existing test case

Use this method to convert a manual test case you previously generated or wrote into an automation script. Instead of describing the test from scratch, you point Test Companion at a test that already has the details filled in.

  1. Open the Test Case Management panel and find the manual test you want to automate.
  2. Click the blue Automate button next to the Test ID to select one or more tests.

    Click the automate button next to a test case to send it to the automation generator

  3. In the chat box, add any instructions beyond what’s in the test case. For example, the application URL or login credentials.
  4. Press Enter to send.

Test Companion reads the test case details, opens a browser to try the flow, and generates the automation code. When it finishes, a new test script file appears in your project and the test case’s Automation Status updates from Not Automated to Automated in the management panel.

Generate API tests

Use this method to create automated tests for a specific API endpoint, URL, or API specification.

  1. Open the Test Companion panel in VS Code.
  2. In the chat box, describe the API you want to test. Include the endpoint URL and any relevant details (authentication, expected response format).

    Provide context before you generate test cases using file attachments, @ references, and rules

  3. Press Enter.

Test Companion then:

  1. Analyzes your project (if available): Reads files like package.json and existing test configs to understand your framework and project structure.
  2. Calls the API: Makes a live request to the target endpoint to get a real response.
  3. Generates a test plan: Creates a discovery summary covering response status, headers, data schema, error codes, and edge cases.
  4. Writes the test file: Generates a new test script in the correct format for your project and adds it to your workspace.

Best practices

The more detail you provide in your test case or prompt, the more accurate the result.

  • Include the application URL so Test Companion knows where to navigate. Without it, it will ask you before proceeding.
  • Provide credentials and test data if the test involves authentication or specific input values.
  • Write clear, discrete steps in your manual test case. Vague steps like “complete the form” produce vague automation. Specific steps like “enter ‘john@example.com’ in the Email field, click Sign In” produce precise, reliable scripts.
  • Mention expected outcomes explicitly. If the test should assert a specific URL, visible element, toast message, or status code, say so.
  • Review generated scripts before running. Always review to ensure generated code matches your project’s patterns and environment.
  • Start with a few tests. Automate a small set of critical tests first, review the code quality, then scale up.

Example prompts

UI automation from scratch:

Write a Cypress test that adds an item to the shopping cart on localhost:3000/shop,
then verifies the cart count updates to 1.

Convert existing tests:

Automate the selected test cases as Playwright tests. Use the Page Object Model pattern
and store page objects in a /pages directory.

API tests:

Generate API tests for the GET /api/v1/products endpoint at example.com.
Test the response status, pagination headers, and data schema validation.

Next steps

  • Manage test cases: Track automation status and organize your test cases.
  • Fix failed tests: When your automation scripts fail in CI/CD, use Test Companion to diagnose and fix them.

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