October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Use AI Prompts for Test Automation in Cypress

Cypress’s cy.prompt() turns clear natural-language steps into executable commands. Learn how to write prompts, handle placeholders, inspect output, and choose a workflow.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Cypress’s cy.prompt() to turn ordered, plain-English test steps into Cypress commands. Write one specific action per step, inspect the generated commands in the Command Log, and verify that the assertions check the behavior you actually intend. You can export the result as regular Cypress code or keep the prompt in your test so Cypress can regenerate commands when a cached selector stops working.

What cy.prompt() does

cy.prompt() accepts an array of natural-language steps. Cypress interprets those steps in the context of the application’s DOM, generates Cypress commands, and executes them. You can inspect the generated commands in the Command Log. This is a way to express test actions in natural language—not a guarantee that the generated test is correct or that its assertions capture your product requirements.

As an Amazon Associate I earn from qualifying purchases.

Cypress says English is the optimized prompt language and does not guarantee accuracy or support for prompts in other languages. Prompt clarity matters: name the target element, give its context when needed, and describe an observable outcome rather than asking for something vague like “check success.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write a useful prompt, step by step

  1. Start with an imperative action. Use verbs such as “visit,” “type,” “click,” and “verify.”
  2. Keep each step to one action. Smaller steps make the intended sequence easier to inspect.
  3. Identify the target precisely. If a page has multiple buttons, specify the label and location, such as the “Edit Profile” button in the profile section.
  4. Use an absolute URL for navigation. Cypress advises including the full URL in a visit step.
  5. Describe the expected result explicitly. Give the exact message or visible state when you know it.
  6. Inspect the generated commands and validate the test. Confirm that the commands select the right elements and that each assertion represents the intended behavior.

For example, this illustrates the documented syntax and placeholder pattern; it is not a tested spec for a particular application, and its steps may need adjustment to match your page:

cy.prompt([
  'visit https://example.test/login',
  'type {{email}} in the email field',
  'type {{password}} in the password field',
  'click the Sign in button',
  'verify the account dashboard is visible',
], {
  placeholders: {
    email: testEmail,
    password: testPassword,
  },
})

The example assumes testEmail and testPassword are already defined in your test setup. The application’s field labels, button text, and dashboard state must match what the prompt describes.

Natural-language command options

Cypress documents force and timeout as the currently supported options that can be expressed in prompts. Check the Cypress API reference for the current syntax and limits before relying on other command options; do not assume that every Cypress command option can be requested in natural language.

Choose whether to keep or export the generated test

Workflow Best fit Trade-off
Generate once, inspect, export, and commit ordinary Cypress code Teams that want source-controlled tests that run without an AI request each time Review and update selectors as the application changes.
Keep cy.prompt() in the test Teams that want Cypress to regenerate code when a cached selector fails after a UI change The test workflow continues to depend on a Cloud-backed AI feature. Inspect regenerated commands and confirm they still test the intended behavior.

Cypress makes generated commands visible in the Command Log and supports exporting them. Regeneration can help when selectors change, but it is not a promise that a test will preserve its meaning after every application change. Treat generated code as code to review, not as an authoritative specification.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set up Cloud access and handle values safely

Cypress says cy.prompt() needs a secure Cypress Cloud connection to interpret prompts. The documented access paths are a Cypress Cloud login or a recorded run using --record with a valid key. Cypress’s guide says the free Starter plan includes cy.prompt(); paid plans raise usage allowances and hourly limits. Plan details can change, so check Cypress’s current plan and feature terms before choosing a plan.

Cypress also states that prompts are not used to train AI models and that AI features can be turned off. Those are Cypress’s statements about its service; consult its current data terms and settings for the details that apply to your account.

Use placeholders for dynamic or sensitive inputs

Put changing values in named {{placeholder}} references and pass the values through the placeholders option. Cypress says placeholder values are not sent to the AI and do not change the cache identity, so changing a value does not invalidate cached generated code. Keep credentials in your project’s normal secret-management system; placeholder support is not a replacement for secret storage.

Troubleshoot common problems

  • The prompt is interpreted incorrectly: Break compound instructions into individual steps, use direct verbs, and name the element and its context. English is the optimized language; Cypress does not guarantee accuracy or support for other languages.
  • The wrong control is selected: Replace generic wording such as “click button” with the visible label and a location, for example the button within a named section. Inspect the generated command in the Command Log.
  • The visit step does not reach the intended page: Use the full absolute URL in the prompt and verify that the test environment serves that address.
  • The prompt cannot be interpreted through Cloud: Check that Cypress has a secure Cloud connection through a Cloud login or a recorded execution with a valid key.
  • A changed placeholder unexpectedly affects a test: Confirm the string uses the exact {{name}} reference and that the corresponding name is supplied in placeholders. Keep the test value defined in the test setup.
  • A regenerated test passes but may test the wrong behavior: Review the generated commands and assertion against the product requirement. A successful run alone does not establish that the assertion is meaningful.

When another Cypress AI workflow fits better

cy.prompt() is for turning natural-language steps into executable Cypress commands. Cypress also documents Studio and Studio AI for recording interactions and suggesting assertions, as well as AI Skills and tools including cypress tap, Cloud MCP, and Cloud CLI for coding-agent workflows, live test debugging, and Cloud run analysis. These are adjacent capabilities, not alternate names for cy.prompt(); choose based on whether you need test authoring, agent context, or debugging.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API, not a replacement for Cypress or cy.prompt(). It can be useful when you need to capture a page as a separate artifact rather than author an interactive test. One GET request returns a screenshot or PDF; its documented options include custom CSS and JavaScript, viewport and device settings, full-page capture, and element capture. The call below requests a WebP screenshot of a page:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.test/login -o shot.webp

See the ScreenshotNeo API documentation for request options. It accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents. Its free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month, with no card.

Frequently Asked Questions

Can I prompt Cypress in a language other than English?

Cypress says English is the optimized prompt language and does not guarantee accuracy or support for non-English prompts.

Does cy.prompt() remove the need to review assertions?

No. Inspect the generated commands and verify that the assertions represent the behavior your test is meant to protect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.