mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-22 16:18:45 -05:00
91bb010fd6
- go into more detail on trigger vs action commands - explain actionability further - better format notes + examples - consistent no arg / arg examples - es6 all the functions - remove duplicated intractability content - remove simulated events garbage - go into more detail on pseudo action commands - much better cy.contains usage
94 lines
1.8 KiB
Markdown
94 lines
1.8 KiB
Markdown
---
|
|
title: window
|
|
comments: false
|
|
---
|
|
|
|
Get the `window` object of the page that is currently active.
|
|
|
|
# Syntax
|
|
|
|
```javascript
|
|
cy.window()
|
|
cy.window(options)
|
|
```
|
|
|
|
## Usage
|
|
|
|
**{% fa fa-check-circle green %} Correct Usage**
|
|
|
|
```javascript
|
|
cy.window()
|
|
```
|
|
|
|
## Arguments
|
|
|
|
**{% fa fa-angle-right %} options** ***(Object)***
|
|
|
|
Pass in an options object to change the default behavior of `cy.window()`.
|
|
|
|
Option | Default | Description
|
|
--- | --- | ---
|
|
`log` | `true` | {% usage_options log %}
|
|
`timeout` | {% url `defaultCommandTimeout` configuration#Timeouts %} | {% usage_options timeout cy.window %}
|
|
|
|
## Yields {% helper_icon yields %}
|
|
|
|
{% yields sets_subject cy.window 'yields the `window` object' %}
|
|
|
|
# Examples
|
|
|
|
## No Args
|
|
|
|
***Yields the remote window object***
|
|
|
|
```javascript
|
|
cy.visit('http://localhost:8080/app')
|
|
cy.window().then(function(win){
|
|
// win is the remote window
|
|
// of the page at: http://localhost:8080/app
|
|
})
|
|
```
|
|
|
|
## Options
|
|
|
|
***Passes timeout through to {% url `.should()` should %} assertion***
|
|
|
|
```javascript
|
|
cy.window({ timeout: 10000 }).should('have.property', 'foo')
|
|
```
|
|
|
|
# Rules
|
|
|
|
## Requirements {% helper_icon requirements %}
|
|
|
|
{% requirements parent cy.window %}
|
|
|
|
## Assertions {% helper_icon assertions %}
|
|
|
|
{% assertions retry cy.window %}
|
|
|
|
## Timeouts {% helper_icon timeout %}
|
|
|
|
{% timeouts assertions cy.window %}
|
|
|
|
# Command Log
|
|
|
|
***Get the window***
|
|
|
|
```javascript
|
|
cy.window()
|
|
```
|
|
|
|
The commands above will display in the command log as:
|
|
|
|

|
|
|
|
When clicking on `window` within the command log, the console outputs the following:
|
|
|
|

|
|
|
|
# See also
|
|
|
|
- {% url `cy.visit()` visit %}
|
|
- {% url `cy.document()` document %}
|