You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/commands/prompt.mdx
+59-5Lines changed: 59 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: 'cy.prompt() - Generate Cypress Tests with Natural Language and AI'
3
-
description: Generate Cypress tests from plain English using AI. Automate test creation, reduce maintenance, and enable self-healing with cy.prompt.
3
+
description: AI-powered Cypress command for developers and QA teams. Generate Cypress tests from plain English, get self-healing selectors, and reduce end-to-end test maintenance with cy.prompt.
`cy.prompt` is a Cypress command that uses AI to convert natural language test steps into executable Cypress tests. You can view the generated Cypress code at any time using the **Code** button in the Command Log, giving you full visibility into what commands were created from your prompts.
14
+
`cy.prompt` is a Cypress command that uses AI to convert natural language test steps into executable Cypress tests. It helps developers and QA engineers generate tests faster, experiment with self-healing end-to-end tests, and reduce ongoing test maintenance. You can view the generated Cypress code at any time using the **Code** button in the Command Log, giving you full visibility into what commands were created from your prompts.
15
15
16
16
**`cy.prompt` supports two flexible workflows:**
17
17
@@ -28,7 +28,8 @@ You can choose the workflow that fits your project's needs.
28
28
-[Choosing your workflow](#Choose-your-workflow) — decide between one-time generation or continuous self-healing
29
29
-[How to write effective prompts](#How-to-write-effective-prompts) — craft clear, reliable natural language steps
30
30
-[What you can do](#What-you-can-do) — explore supported actions and capabilities
31
-
-[Viewing and exporting generated code](#Viewing-and-exporting-generated-code) — see the Cypress code generated from your prompts and save it to your files
31
+
-[See self-healed steps in the Command Log](#See-self-healed-steps-in-the-Command-Log) — understand exactly what changed and which element the step resolved to
32
+
-[View and export generated code](#View-and-export-generated-code) — see the Cypress code generated from your prompts and save it to your files
32
33
-[Setup](#Setup) — enable the command and configure authentication
33
34
34
35
:::
@@ -41,6 +42,12 @@ You can choose the workflow that fits your project's needs.
41
42
42
43
_The demo above shows `cy.prompt` in action with [Cypress Studio](/app/guides/cypress-studio)._
43
44
45
+
## Why use cy.prompt for AI-powered testing?
46
+
47
+
-**Reduce test maintenance**: Let AI and self-healing selectors absorb many minor UI changes instead of constantly updating selectors by hand.
48
+
-**Accelerate test creation**: Turn plain-English test ideas into runnable Cypress tests without having to hand-write every command.
49
+
-**Improve collaboration**: Product owners, QA, and developers can all contribute natural language steps that become real tests.
cy.prompt self-heals when the element it needs to interact with has changed since the last time the step ran, enabling self-healing Cypress tests that adapt as your UI evolves.
395
+
396
+
When `cy.prompt` self-heals a step, Cypress makes that change visible directly in the Command Log so you can understand exactly what changed and which element the step resolved to.
alt="Console logs for a self-healed cy.prompt step"
414
+
/>
415
+
416
+
### Console logs
417
+
418
+
Clicking a `cy.prompt` command or an individual self-healed step prints detailed Console logs in the Developer Tools, including:
419
+
420
+
-**Resolved element** - The selector and element that this step resolved to after self-healing.
421
+
-**Cached elements** - The previously resolved elements that the step checked before self-healing.
422
+
-**Self-healed** - Whether the element was self-healed.
423
+
424
+
If the element was self-healed via cache, the Console logs will show the resolved element within the cached elements. If the element was self-healed via AI, the Console logs will not have the resolved element within the cached elements.
alt="Console logs for a self-healed cy.prompt step"
429
+
/>
430
+
431
+
This level of detail makes it easy to tell whether a self-heal reflects an intentional product change or an unexpected behavior so you can refine or rewrite the step if necessary.
432
+
433
+
### Self-healed status definitions
434
+
435
+
**Self-Healed via Cache** - A selector changed since the last time `cy.prompt` ran and the element resolved to another element using the existing cache entry. In this case, `cy.prompt` did **not** call AI; the cached mapping was able to resolve the new element.
436
+
437
+
**Self-Healed via AI** - A selector changed since the last time `cy.prompt` ran and the element resolved to another element via an AI call because there was no matching cache entry.
438
+
439
+
## View and export generated code
386
440
387
-
At any time during or after a test run, you can view the exact Cypress code that `cy.prompt` generated from your natural language steps. This transparency is built into every `cy.prompt` execution.
441
+
At any time during or after a test run, you can view the exact Cypress code that `cy.prompt` generated from your natural language steps. Combined with the self-healed tags and Console details in the Command Log, this gives you a clear, auditable record of what happened during `cy.prompt` execution so you can debug AI-generated tests and reduce flaky end-to-end tests over time. This transparency is built into every `cy.prompt` execution.
0 commit comments