mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-21 15:49:19 -05:00
119 lines
2.7 KiB
Markdown
119 lines
2.7 KiB
Markdown
---
|
|
title: pause
|
|
comments: false
|
|
---
|
|
|
|
Stop `cy` commands from running and allow interaction with the application under test. You can then "resume" running all commands or choose to step through the "next" commands from the Command Log.
|
|
|
|
{% note info %}
|
|
This does not set a `debugger` in your code, unlike {% url `.debug()` debug %}
|
|
{% endnote %}
|
|
|
|
# Syntax
|
|
|
|
```javascript
|
|
.pause()
|
|
.pause(options)
|
|
```
|
|
|
|
## Usage
|
|
|
|
**{% fa fa-check-circle green %} Correct Usage**
|
|
|
|
```javascript
|
|
cy.pause().getCookie('app') // Pause at the beginning of commands
|
|
cy.get('nav').pause() // Pause after the 'get' commands yield
|
|
```
|
|
|
|
## Arguments
|
|
|
|
**{% fa fa-angle-right %} options** ***(Object)***
|
|
|
|
Pass in an options object to change the default behavior of `.pause()`.
|
|
|
|
Option | Default | Description
|
|
--- | --- | ---
|
|
`log` | `true` | {% usage_options log %}
|
|
|
|
## Yields {% helper_icon yields %}
|
|
|
|
{% yields same_subject .pause %}
|
|
|
|
# Examples
|
|
|
|
## Pause
|
|
|
|
**Pause after assertion**
|
|
|
|
```javascript
|
|
cy.get('a').should('have.attr', 'href').and('match', /dashboard/).pause()
|
|
cy.get('button').should('not.be.disabled')
|
|
```
|
|
|
|
# Rules
|
|
|
|
## Requirements {% helper_icon requirements %}
|
|
|
|
{% requirements dual .pause %}
|
|
|
|
## Assertions {% helper_icon assertions %}
|
|
|
|
{% assertions utility .pause %}
|
|
|
|
## Timeouts {% helper_icon timeout %}
|
|
|
|
{% timeouts none .pause %}
|
|
|
|
# Command Log
|
|
|
|
**Pause and step through each `.click()` command**
|
|
|
|
```javascript
|
|
cy.get('#action-canvas')
|
|
.click(80, 75)
|
|
.pause()
|
|
.click(170, 75)
|
|
.click(80, 165)
|
|
.click(100, 185)
|
|
.click(125, 190)
|
|
.click(150, 185)
|
|
.click(170, 165)
|
|
```
|
|
|
|
The commands above will display in the GUI as:
|
|
|
|

|
|
|
|
When clicking on "Next: 'click'" at the top of the Command Log, the Command Log will run only the next command and pause again.
|
|
|
|
***Click "Next"***
|
|
|
|

|
|
|
|
***Click "Next" again***
|
|
|
|

|
|
|
|
***Click "Next" again***
|
|
|
|

|
|
|
|
***Click "Next" again***
|
|
|
|

|
|
|
|
***Click "Next" again***
|
|
|
|

|
|
|
|
***Click "Next" again, then 'Resume'***
|
|
|
|

|
|
|
|
# See also
|
|
|
|
- {% url 'Dashboard' https://on.cypress.io/dashboard %}
|
|
- {% url `cy.debug()` debug %}
|
|
- {% url `cy.log()` log %}
|
|
- {% url `cy.screenshot()` screenshot %}
|