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
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,29 @@ cy.prompt(
66
66
67
67
<HeaderYields />
68
68
69
-
-`cy.prompt()` yields `null`.
69
+
`cy.prompt()` yields the value yielded by the last Cypress command executed in the prompt. In most cases, this will be an element, but it depends on the last command executed in the prompt.
70
+
71
+
```javascript
72
+
cy.prompt([
73
+
// Executes cy.visit('/user-management')
74
+
'visit https://cloud.cypress.io/login',
75
+
// Executes cy.get('#login-button').click()
76
+
'click the login button',
77
+
]) // yields <button> since .click() yields the same subject it was originally given.
78
+
.closest('form')
79
+
.submit()
80
+
```
81
+
82
+
In the example below, the last command executed in the prompt is `.visit()`, so the yielded value is the window object.
83
+
84
+
```javascript
85
+
cy.prompt([
86
+
// Executes cy.visit('/user-management')
87
+
'visit https://cloud.cypress.io/login',
88
+
]) // yields window object since .visit() yields window object
0 commit comments