> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spurtest.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Script to Test Generation

> Import existing Playwright, Selenium or other automation scripts and transform them into Spur test steps that can be executed with the Spur Agent.

## Overview

Script to Test Generation bridges the gap between traditional automation frameworks and Spur's natural language testing approach.

By importing scripts, you can quickly migrate existing test coverage to Spur without manual rewriting, while maintaining the test logic and validation steps you've already developed.

**Supported Script Types:**

* Playwright scripts (.js, .ts)
* Selenium scripts (.py, .js, .java)
* Cypress scripts (.js)
* Puppeteer scripts (.js)

## How to Generate Spur Tests from Scripts

<Steps>
  <Step title="Navigate to Dashboard and Create a New Test">
    Open your Spur Dashboard. Click **New** and choose **Test** from the dropdown menu to begin the test creation process.

    <Frame>
      <img src="https://mintcdn.com/spur/RaeB6Oz5SVRJ2dhu/images/newtest.gif?s=3a279c4008f82a7179dc79f6f9d743b6" alt="Newtest" width="2172" height="1080" data-path="images/newtest.gif" />
    </Frame>
  </Step>

  <Step title="Name Your Test and Select Test Suite">
    Enter a name for your test and add it to an existing Test Suite or create a new one. Click **Create Test** to proceed.

    <Frame>
      <img src="https://mintcdn.com/spur/BvhWQtDOy3g9ZJZN/images/step2.png?fit=max&auto=format&n=BvhWQtDOy3g9ZJZN&q=85&s=0e544aebdf9eda8eceacc321c70c9c49" alt="Step2" width="892" height="604" data-path="images/step2.png" />
    </Frame>
  </Step>

  <Step title="Configure Test URL">
    The Test Editing Side Peek will open and fill in the Test URL field. Reference [Environments](/authoring-tests/environments/environments) for configuring environment-specific URLs.

    <Frame>
      <img src="https://mintcdn.com/spur/BvhWQtDOy3g9ZJZN/images/step3.png?fit=max&auto=format&n=BvhWQtDOy3g9ZJZN&q=85&s=6100425c84e2aa8f9b97bd366fa7e704" alt="Step3" width="1466" height="914" data-path="images/step3.png" />
    </Frame>
  </Step>

  <Step title="Navigate to Auto-Generate and Click From Code">
    Locate the **Auto-generate** button in the Test Steps section and click **From Code** to access the script import feature.

    <Frame>
      <img src="https://mintcdn.com/spur/RaeB6Oz5SVRJ2dhu/images/naviagtetocodeintextstep4-1.gif?s=c42315a53936e9fbec7dd74c9b6b531b" alt="Naviagtetocodeintextstep4 1" width="1720" height="1080" data-path="images/naviagtetocodeintextstep4-1.gif" />
    </Frame>
  </Step>

  <Step title="Import Your Script">
    The **Import Test from Script** modal will appear. Choose your script file and click **Import Steps** to begin the conversion process.

    <Frame>
      <img src="https://mintcdn.com/spur/BvhWQtDOy3g9ZJZN/images/step5.gif?s=6d5275a12f8b41defd050cceae6b95f2" alt="Step5" width="1788" height="1080" data-path="images/step5.gif" />
    </Frame>
  </Step>

  <Step title="Configure and Save">
    All imported test steps now appear in the Test Editing Side Peek. Configure viewport settings, [Advanced Configurations](/authoring-tests/test-side-peek/advanced-configurations), and caching options as needed. Reference [Create Your First Test](/getting-started/first-test) for detailed guidance on these settings.

    Click **Save Test** when complete.

    <Frame>
      <img src="https://mintcdn.com/spur/lrrfi2BWgTMkxyYA/images/step6.gif?s=4c9a3053d2c30023b45afcd122c3528f" alt="Step6" width="1720" height="1080" data-path="images/step6.gif" />
    </Frame>
  </Step>

  <Step title="View Your Created Test">
    Your test from script has been created successfully. Navigate to the test suite where you saved your test to view, run, or edit it.

    <Frame>
      <img src="https://mintcdn.com/spur/lrrfi2BWgTMkxyYA/images/step7.png?fit=max&auto=format&n=lrrfi2BWgTMkxyYA&q=85&s=c738bc73c927f9984420c6897b13d529" alt="Step7" width="2092" height="500" data-path="images/step7.png" />
    </Frame>
  </Step>
</Steps>

## Best Practices

1. **Review all imported steps**: Always verify that converted steps match your testing intent. The AI conversion is highly accurate but may require minor adjustments.
2. **Leverage Preview Editor**: After import, use the [Preview Editor](/authoring-tests/preview-editor) to validate and refine test steps with live browser feedback.
3. **Maintain test organization**: Import scripts into appropriate test suites to maintain clear test organization and facilitate team collaboration.
