Files
cypress/docs/source/api/commands/window.md
T
Brian Mann 91bb010fd6 docs: fixes #231, cleanup all the API docs + notes
- 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
2017-06-30 18:33:52 -04:00

1.8 KiB

title, comments
title comments
window false

Get the window object of the page that is currently active.

Syntax

cy.window()
cy.window(options)

Usage

{% fa fa-check-circle green %} Correct Usage

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

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

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

cy.window()

The commands above will display in the command log as:

Command Log

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

Console Log

See also

  • {% url cy.visit() visit %}
  • {% url cy.document() document %}