mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 07:34:00 -05:00
Merge branch 'master' into 0.20.0-desktop-gui-changes
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
exports['passes --browser option 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--cli-version",
|
||||
"0.19.2",
|
||||
"--browser",
|
||||
"test browser"
|
||||
]
|
||||
|
||||
exports['removes --record option when using --browser 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--cli-version",
|
||||
"0.19.2",
|
||||
"--browser",
|
||||
"test browser"
|
||||
]
|
||||
|
||||
exports['passes --record option 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--record",
|
||||
"my record id",
|
||||
"--cli-version",
|
||||
"0.19.2"
|
||||
]
|
||||
|
||||
exports['does not remove --record option when using --browser 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--record",
|
||||
"foo",
|
||||
"--cli-version",
|
||||
"0.19.2",
|
||||
"--browser",
|
||||
"test browser"
|
||||
]
|
||||
|
||||
+7
-1
@@ -1,11 +1,12 @@
|
||||
const _ = require('lodash')
|
||||
const commander = require('commander')
|
||||
const { oneLine } = require('common-tags')
|
||||
|
||||
const coerceFalse = (arg) => {
|
||||
return arg !== 'false'
|
||||
}
|
||||
|
||||
const parseOpts = (opts) => _.pick(opts, 'spec', 'reporter', 'reporterOptions', 'path', 'destination', 'port', 'env', 'cypressVersion', 'config', 'record', 'key')
|
||||
const parseOpts = (opts) => _.pick(opts, 'spec', 'reporter', 'reporterOptions', 'path', 'destination', 'port', 'env', 'cypressVersion', 'config', 'record', 'key', 'browser')
|
||||
|
||||
const descriptions = {
|
||||
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',
|
||||
@@ -16,6 +17,10 @@ const descriptions = {
|
||||
port: 'runs Cypress on a specific port. overrides any value in cypress.json. defaults to "2020"',
|
||||
env: 'sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json',
|
||||
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.',
|
||||
browser: oneLine`
|
||||
runs Cypress in the browser with the given name.
|
||||
note: using an external browser will cancel video recording of tests.
|
||||
`,
|
||||
}
|
||||
|
||||
const text = (description) => {
|
||||
@@ -42,6 +47,7 @@ module.exports = {
|
||||
.option('-p, --port <port>', text('port'))
|
||||
.option('-e, --env <env>', text('env'))
|
||||
.option('-c, --config <config>', text('config'))
|
||||
.option('-b, --browser <browser name>', text('browser'))
|
||||
.action((opts) => require('./exec/run').start(parseOpts(opts)))
|
||||
|
||||
program
|
||||
|
||||
@@ -3,8 +3,9 @@ const chalk = require('chalk')
|
||||
const download = require('./download')
|
||||
const utils = require('./utils')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
|
||||
const packageVersion = require('../../package').version
|
||||
const path = require('path')
|
||||
const packagePath = path.join(__dirname, '..', '..', 'package.json')
|
||||
const packageVersion = require(packagePath).version
|
||||
|
||||
const hasSomethingToSay = (err) => err && err.message
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ const ProgressBar = require('progress')
|
||||
|
||||
const xvfb = require('../exec/xvfb')
|
||||
const { formErrorText, errors } = require('./errors')
|
||||
const packageVersion = require('../../package').version
|
||||
const packagePath = path.join(__dirname, '..', '..', 'package.json')
|
||||
const packageVersion = require(packagePath).version
|
||||
|
||||
const log = (...messages) => {
|
||||
console.log(...messages) // eslint-disable-line no-console
|
||||
|
||||
+14
-2
@@ -2,9 +2,11 @@ const _ = require('lodash')
|
||||
|
||||
const downloadUtils = require('../download/utils')
|
||||
const spawn = require('./spawn')
|
||||
const pkg = require('../../package')
|
||||
const path = require('path')
|
||||
const packagePath = path.join(__dirname, '..', '..', 'package.json')
|
||||
const pkg = require(packagePath)
|
||||
|
||||
const run = (options) => () => {
|
||||
const processRunOptions = (options = {}) => {
|
||||
const args = ['--run-project', options.project]
|
||||
|
||||
//// if key is set use that - else attempt to find it by env var
|
||||
@@ -65,10 +67,20 @@ const run = (options) => () => {
|
||||
//// send in the CLI version
|
||||
args.push('--cli-version', pkg.version)
|
||||
|
||||
if (options.browser) {
|
||||
args.push('--browser', options.browser)
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
const run = (options) => () => {
|
||||
const args = processRunOptions(options)
|
||||
return spawn.start(args)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
processRunOptions,
|
||||
start (options = {}) {
|
||||
_.defaults(options, {
|
||||
key: null,
|
||||
|
||||
@@ -2,6 +2,7 @@ const _ = require('lodash')
|
||||
const cp = require('child_process')
|
||||
const chalk = require('chalk')
|
||||
const Promise = require('bluebird')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
|
||||
const downloadUtils = require('../download/utils')
|
||||
const xvfb = require('./xvfb')
|
||||
@@ -20,7 +21,12 @@ module.exports = {
|
||||
|
||||
const spawn = () => {
|
||||
return new Promise((resolve) => {
|
||||
const child = cp.spawn(downloadUtils.getPathToExecutable(), args, options)
|
||||
const cypressPath = downloadUtils.getPathToExecutable()
|
||||
debug('spawning Cypress %s', cypressPath)
|
||||
debug('args %j', args)
|
||||
debug('some of the options %j', _.pick(options, ['verify', 'detached']))
|
||||
|
||||
const child = cp.spawn(cypressPath, args, options)
|
||||
if (needsXvfb) {
|
||||
//// make sure we close down xvfb
|
||||
//// when our spawned process exits
|
||||
|
||||
+7
-3
@@ -11,7 +11,8 @@
|
||||
"test-unit": "mocha",
|
||||
"test-watch": "mocha --watch",
|
||||
"lint": "$(bin-up eslint) --fix *.js bin/* lib/*.js lib/**/*.js test/*.js test/**/*.js",
|
||||
"pretest": "npm run lint"
|
||||
"pretest": "npm run lint && npm run test-dependencies",
|
||||
"test-dependencies": "deps-ok && dependency-check . --no-dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"bluebird": "^3.4.5",
|
||||
@@ -27,19 +28,22 @@
|
||||
"lodash": "^4.16.3",
|
||||
"minimist": "^1.2.0",
|
||||
"progress": "^1.1.8",
|
||||
"ramda": "^0.24.1",
|
||||
"request": "^2.81.0",
|
||||
"request-progress": "^0.3.1",
|
||||
"tmp": "0.0.31",
|
||||
"url": "^0.11.0",
|
||||
"xvfb": "cypress-io/node-xvfb"
|
||||
"xvfb": "cypress-io/node-xvfb",
|
||||
"yauzl": "^2.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bin-up": "^1.0.1",
|
||||
"chai": "^3.5.0",
|
||||
"clear-module": "^2.1.0",
|
||||
"dependency-check": "^2.8.0",
|
||||
"deps-ok": "^1.2.0",
|
||||
"mocha": "^3.2.0",
|
||||
"nock": "^9.0.9",
|
||||
"ramda": "^0.24.1",
|
||||
"sinon": "^2.1.0",
|
||||
"sinon-chai": "^2.9.0",
|
||||
"snap-shot": "^2.17.0"
|
||||
|
||||
@@ -7,12 +7,37 @@ const downloadUtils = require('../../lib/download/utils')
|
||||
const cli = require('../../lib/cli')
|
||||
const spawn = require('../../lib/exec/spawn')
|
||||
const run = require('../../lib/exec/run')
|
||||
const snapshot = require('snap-shot')
|
||||
|
||||
describe('exec run', function () {
|
||||
beforeEach(function () {
|
||||
this.sandbox.stub(process, 'exit')
|
||||
})
|
||||
|
||||
context('#processRunOptions', function () {
|
||||
it('passes --browser option', () => {
|
||||
const args = run.processRunOptions({
|
||||
browser: 'test browser',
|
||||
})
|
||||
snapshot(args)
|
||||
})
|
||||
|
||||
it('passes --record option', () => {
|
||||
const args = run.processRunOptions({
|
||||
record: 'my record id',
|
||||
})
|
||||
snapshot(args)
|
||||
})
|
||||
|
||||
it('does not remove --record option when using --browser', () => {
|
||||
const args = run.processRunOptions({
|
||||
record: 'foo',
|
||||
browser: 'test browser',
|
||||
})
|
||||
snapshot(args)
|
||||
})
|
||||
})
|
||||
|
||||
context('cli interface', function () {
|
||||
beforeEach(function () {
|
||||
this.sandbox.stub(run, 'start')
|
||||
|
||||
@@ -25,6 +25,18 @@ public_dir: public
|
||||
i18n_dir: :lang
|
||||
skip_render:
|
||||
|
||||
# Generate alias pages for redirecting to posts, pages or URL
|
||||
# You must run `npm run build` for changes to take effect
|
||||
# https://github.com/hexojs/hexo-generator-alias
|
||||
alias:
|
||||
index.html: guides/getting-started/why-cypress.html
|
||||
guides/index.html: guides/getting-started/why-cypress.html
|
||||
api/index.html: api/welcome/api.html
|
||||
examples/index.html: examples/recipes/unit-testing.html
|
||||
faq/index.html: faq/questions/general-questions.html
|
||||
# can also do outside page links here
|
||||
# plugins/index.html: https://github.com/cypress/cypress/wiki/Plugins
|
||||
|
||||
# Include/Exclude Files/Folders
|
||||
include:
|
||||
- api/utilities/** ## This ensures that our '_.md' file is included
|
||||
|
||||
+46
-17
@@ -10,6 +10,9 @@ const errors = require('request-promise/errors')
|
||||
const startsWithHttpRe = /^http/
|
||||
const everythingAfterHashRe = /(#.+)/
|
||||
|
||||
// cache validations
|
||||
const cache = {}
|
||||
|
||||
function isExternalHref (str) {
|
||||
return startsWithHttpRe.test(str)
|
||||
}
|
||||
@@ -29,24 +32,29 @@ function assertHashIsPresent (descriptor, source, hash, html) {
|
||||
// verify that the hash is present on this page
|
||||
const $ = cheerio.load(html)
|
||||
|
||||
// hash starts with a '#'
|
||||
if (!$(hash).length) {
|
||||
const truncated = _.truncate(html, { length: 200 }) || '""'
|
||||
|
||||
// if we dont have a hash
|
||||
throw new Error(`Constructing {% url %} tag helper failed
|
||||
|
||||
> The source file was: ${source}
|
||||
|
||||
> You referenced a hash that does not exist at: ${descriptor}
|
||||
|
||||
> Expected to find an element matching the id: ${hash}
|
||||
|
||||
> The HTML response body was:
|
||||
|
||||
${truncated}
|
||||
`)
|
||||
// hash starts with a '#hash'
|
||||
// or href starts with '#hash'
|
||||
if ($(hash).length || $(`a[href=${hash}]`).length) {
|
||||
// found it, we good!
|
||||
return
|
||||
}
|
||||
|
||||
// we didnt find anything, so throw the errror
|
||||
const truncated = _.truncate(html, { length: 200 }) || '""'
|
||||
|
||||
// if we dont have a hash
|
||||
throw new Error(`Constructing {% url %} tag helper failed
|
||||
|
||||
> The source file was: ${source}
|
||||
|
||||
> You referenced a hash that does not exist at: ${descriptor}
|
||||
|
||||
> Expected to find an element matching the id: ${hash} or href: ${hash}
|
||||
|
||||
> The HTML response body was:
|
||||
|
||||
${truncated}
|
||||
`)
|
||||
}
|
||||
|
||||
function validateExternalUrl (href, source) {
|
||||
@@ -161,15 +169,36 @@ function validateLocalFile (sidebar, href, source, render) {
|
||||
}
|
||||
|
||||
function validateAndGetUrl (sidebar, href, source, render) {
|
||||
// do we already have a cache for this href?
|
||||
const cachedValue = cache[href]
|
||||
|
||||
// if we got it, return it!
|
||||
if (cachedValue) {
|
||||
return Promise.resolve(cachedValue)
|
||||
}
|
||||
|
||||
if (isExternalHref(href)) {
|
||||
// cache this now even though
|
||||
// we haven't validated it yet
|
||||
// because it will just fail later
|
||||
cache[href] = href
|
||||
|
||||
return validateExternalUrl(href, source)
|
||||
.return(href)
|
||||
}
|
||||
|
||||
return validateLocalFile(sidebar, href, source, render)
|
||||
.then((pathToFile) => {
|
||||
// cache this once its been locally resolved
|
||||
cache[href] = pathToFile
|
||||
|
||||
return pathToFile
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
cache,
|
||||
|
||||
normalizeNestedPaths,
|
||||
|
||||
findFileBySource,
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
"hexo": "github:cypress-io/hexo#d709e91b9a014d01215bcebc7299ea3e2ad9153d",
|
||||
"hexo-algoliasearch": "0.2.1",
|
||||
"hexo-filter-cleanup": "1.0.7",
|
||||
"hexo-generator-alias": "0.1.3",
|
||||
"hexo-generator-seo-friendly-sitemap": "0.0.20",
|
||||
"hexo-prism-plugin": "2.0.2",
|
||||
"hexo-renderer-marked": "0.3.0",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
const util = require('hexo-util')
|
||||
const urlGenerator = require('../lib/url_generator')
|
||||
|
||||
@@ -54,6 +55,30 @@ hexo.extend.tag.register('fa', function (args) {
|
||||
return `<i class="fa ${classNames}"></i>`
|
||||
})
|
||||
|
||||
hexo.extend.tag.register('open_an_issue', function (args) {
|
||||
const attrs = {
|
||||
href: 'https://github.com/cypress-io/cypress/issues/new',
|
||||
target: '_blank',
|
||||
}
|
||||
|
||||
const text = args[0] || 'Open an issue'
|
||||
|
||||
return util.htmlTag('a', attrs, text)
|
||||
})
|
||||
|
||||
hexo.extend.tag.register('issue', function (args) {
|
||||
const num = args[0]
|
||||
|
||||
const attrs = {
|
||||
href: `https://github.com/cypress-io/cypress/issues/${num}`,
|
||||
target: '_blank',
|
||||
}
|
||||
|
||||
const text = args[1] || `issue #${num}`
|
||||
|
||||
return util.htmlTag('a', attrs, text)
|
||||
})
|
||||
|
||||
hexo.extend.tag.register('url', function (args) {
|
||||
// {% url `.and()` and %}
|
||||
// {% url `.should()` should#Notes %}
|
||||
@@ -107,3 +132,9 @@ hexo.extend.tag.register('url', function (args) {
|
||||
})
|
||||
|
||||
}, { async: true })
|
||||
|
||||
hexo.extend.tag.register('partial', (fileName) => {
|
||||
const pathToFile = path.resolve('source', '_partial', `${fileName}.md`)
|
||||
|
||||
return hexo.render.render({ path: pathToFile, engine: 'markdown' })
|
||||
}, { async: true })
|
||||
|
||||
@@ -4,15 +4,15 @@ guides:
|
||||
installing-cypress: installing-cypress.html
|
||||
writing-your-first-test: writing-your-first-test.html
|
||||
testing-your-app: testing-your-app.html
|
||||
next-steps: next-steps.html
|
||||
# next-steps: next-steps.html
|
||||
core-concepts:
|
||||
cypress-in-a-nutshell: cypress-in-a-nutshell.html
|
||||
organizing-tests: organizing-tests.html
|
||||
overview-of-the-gui-tool: overview-of-the-gui-tool.html
|
||||
aliases-variables-in-an-async-world: aliases-variables-in-an-async-world.html
|
||||
aliases: aliases.html
|
||||
dead-simple-debugging: dead-simple-debugging.html
|
||||
stubs-spies-clocks: stubs-spies-clocks.html
|
||||
dealing-with-the-network: dealing-with-the-network.html
|
||||
network-requests: network-requests.html
|
||||
taking-screenshots-and-recording-videos: taking-screenshots-and-recording-videos.html
|
||||
integrating-cypress:
|
||||
cli-tool: cli-tool.html
|
||||
@@ -23,7 +23,7 @@ guides:
|
||||
dashboard-features: dashboard-features.html
|
||||
dashboard-projects: dashboard-projects.html
|
||||
dashboard-runs: dashboard-recorded-runs.html
|
||||
dashboard-orgs: dashboard-organizations.html
|
||||
dashboard-organizations: dashboard-organizations.html
|
||||
advanced-cypress:
|
||||
# the-cypress-workflow: the-cypress-workflow.html
|
||||
# coming-from-selenium: coming-from-selenium.html
|
||||
@@ -37,7 +37,7 @@ guides:
|
||||
error-messages: error-messages.html
|
||||
bundled-tools: bundled-tools.html
|
||||
available-assertions: available-assertions.html
|
||||
creating-fixtures: creating-fixtures.html
|
||||
# creating-fixtures: creating-fixtures.html
|
||||
# best-practices: best-practices.html
|
||||
# anti-patterns: anti-patterns.html
|
||||
cypress-api-design: cypress-api-design.html
|
||||
@@ -145,3 +145,23 @@ api:
|
||||
dom: dom.html
|
||||
env: env.html
|
||||
cypress-server: server.html
|
||||
|
||||
examples:
|
||||
recipes:
|
||||
unit-testing: unit-testing.html
|
||||
logging-in: logging-in.html
|
||||
testing-the-dom: testing-the-dom.html
|
||||
working-with-the-backend: working-with-the-backend.html
|
||||
spies-stubs-and-clocks: spies-stubs-and-clocks.html
|
||||
extending-cypress: extending-cypress.html
|
||||
applications:
|
||||
kitchen-sink: kitchen-sink.html
|
||||
todo-mvc: todo-mvc.html
|
||||
pie-chopper: pie-chopper.html
|
||||
phonecat: phonecat.html
|
||||
|
||||
faq:
|
||||
questions:
|
||||
general-questions: general-questions.html
|
||||
using-cypress: using-cypress.html
|
||||
company: company.html
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
**What's the difference between `.then()` and `.should()`/`.and()`?**
|
||||
|
||||
Using `.then()` simply allows you to use the yielded subject in a callback function and should be used when you need to manipulate some values or do some actions.
|
||||
|
||||
When using a callback function with `.should()` or `.and()`, on the other hand, there is special logic to rerun the callback function until no assertions throw within it. You should be careful of side affects in a `.should()` or `.and()` callback function that you would not want performed multiple times.
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: scrollIntoView
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Scroll an element into view.
|
||||
@@ -58,7 +58,7 @@ Option | Default | Notes
|
||||
|
||||
**Snapshots do not reflect scroll behavior**
|
||||
|
||||
*Cypress does not reflect the accurate scroll positions of any elements within snapshots.* If you want to see the actual scrolling behavior in action, we recommend using {% url `.pause()` pause %} to walk through each command or [watching the video of the test run](#https://on.cypress.io/guides/runs#videos).
|
||||
*Cypress does not reflect the accurate scroll positions of any elements within snapshots.* If you want to see the actual scrolling behavior in action, we recommend using {% url `.pause()` pause %} to walk through each command or {% url 'watching the video of the test run' taking-screenshots-and-recording-videos.html#Videos %}.
|
||||
|
||||
# Command Log
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: scrollTo
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Scroll to a specific position.
|
||||
@@ -118,7 +118,7 @@ cy.get('#slider').scrollTo('right', { duration: 2000} )
|
||||
|
||||
**Snapshots do not reflect scroll behavior**
|
||||
|
||||
*Cypress does not reflect the accurate scroll positions of any elements within snapshots.* If you want to see the actual scrolling behavior in action, we recommend using {% url `.pause()` pause %} to walk through each command or [watching the video of the test run](#https://on.cypress.io/guides/runs#videos).
|
||||
*Cypress does not reflect the accurate scroll positions of any elements within snapshots.* If you want to see the actual scrolling behavior in action, we recommend using {% url `.pause()` pause %} to walk through each command or {% url 'watching the video of the test run' taking-screenshots-and-recording-videos.html#Videos %}.
|
||||
|
||||
# Command Log
|
||||
|
||||
@@ -131,11 +131,11 @@ cy.get('#scrollable-horizontal').scrollTo('right')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="529" alt="screen shot 2017-04-14 at 12 29 13 pm" src="https://cloud.githubusercontent.com/assets/1271364/25049157/50d68f18-210e-11e7-81f1-ed837075160d.png">
|
||||

|
||||
|
||||
When clicking on `scrollTo` within the command log, the console outputs the following:
|
||||
|
||||
<img width="788" alt="screen shot 2017-04-14 at 12 32 16 pm" src="https://cloud.githubusercontent.com/assets/1271364/25049182/6e07211a-210e-11e7-9419-b57f3e08a608.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: trigger
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Trigger an event on a DOM element.
|
||||
@@ -90,7 +90,7 @@ cy.get('button').trigger('mouseover') // yields 'button'
|
||||
**Drag and Drop**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe triggering mouse and drag events to test dragging and dropping](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/drag_n_drop_spec.js)
|
||||
{% url 'Check out our example recipe triggering mouse and drag events to test dragging and dropping' 'https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/drag_n_drop_spec.js' %}
|
||||
{% endnote %}
|
||||
|
||||
## Change Event
|
||||
@@ -162,11 +162,11 @@ cy.get('button').first().trigger('mouseover')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="364" alt="Command log output" src="https://cloud.githubusercontent.com/assets/1157043/23477277/749d347e-fe8b-11e6-9c31-6667f7ff65d8.png">
|
||||

|
||||
|
||||
When clicking on `trigger` within the command log, the console outputs the following:
|
||||
|
||||
<img width="630" alt="Console output" src="https://cloud.githubusercontent.com/assets/1157043/23477276/749aac54-fe8b-11e6-81b3-e7600cca0ba0.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: and
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make an assertion.
|
||||
@@ -10,7 +10,7 @@ An alias of {% url `.should()` should %}
|
||||
{% endnote %}
|
||||
|
||||
{% note info %}
|
||||
**Note:** `.and()` assumes you are already familiar with core concepts such as [assertions](https://on.cypress.io/guides/making-assertions)
|
||||
**Note:** `.and()` assumes you are already familiar with core concepts such as {% url 'assertions' cypress-in-a-nutshell#Assertions %}
|
||||
{% endnote %}
|
||||
|
||||
# Syntax
|
||||
@@ -78,13 +78,24 @@ cy
|
||||
|
||||
## Timeout
|
||||
|
||||
`.and()` will continue to retry the assertion to the duration of the previous cy commands `timeout` or the {% url `defaultCommandTimeout` configuration#Timeouts %}.
|
||||
`.and()` will continue to retry until none of the assertions throw for the duration of the previous cy commands `timeout`.
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should('have.value', '10').and('have.class', 'error')
|
||||
↲
|
||||
// timeout here will be passed down to the '.and()'
|
||||
// and it will retry for up to 10 secs
|
||||
// timeout here will be passed down to the '.and()'
|
||||
// and it will retry for up to 10 secs
|
||||
```
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should('have.value', 'US').and(function($input)){
|
||||
↲
|
||||
// timeout here will be passed down to the '.and()'
|
||||
// unless an assertion throws earlier,
|
||||
// ALL of the assertions will retry for up to 10 secs
|
||||
expect($input).to.not.be('disabled')
|
||||
expect($input).to.not.have.class('error')
|
||||
})
|
||||
```
|
||||
|
||||
# Examples
|
||||
@@ -209,7 +220,7 @@ expect({foo: 'bar'}).to.have.property('foo').and.eq('bar')
|
||||
|
||||
The chainers that come from {% url 'Chai' bundled-tools#Chai %} or {% url 'Chai-jQuery' bundled-tools#Chai-jQuery %} will always document what they return.
|
||||
|
||||
You can [read more about debugging assertions](https://on.cypress.io/guides/making-assertions#debugging-assertions) here.
|
||||
{% partial then_should_difference %}
|
||||
|
||||
# Command Log
|
||||
|
||||
@@ -225,13 +236,13 @@ cy
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="530" alt="screen shot 2015-11-29 at 12 16 46 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458700/36d1e646-9693-11e5-8771-158230530fdc.png">
|
||||

|
||||
|
||||
When clicking on `assert` within the command log, the console outputs the following:
|
||||
|
||||
<img width="636" alt="screen shot 2015-11-29 at 12 17 03 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458702/3b6873be-9693-11e5-88f7-a928ebdac80c.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- [Making Assertions](https://on.cypress.io/guides/making-assertions)
|
||||
- {% url 'Assertions' cypress-in-a-nutshell#Assertions %}
|
||||
- {% url `.should()` should %}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: as
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Assign an alias for later use. Reference the alias later within a {% url `cy.get()` get %} or {% url `cy.wait()` wait %} command with a `@` prefix.
|
||||
|
||||
{% note info %}
|
||||
**Note:** `.as()` assumes you are already familiar with core concepts such as [aliases](https://on.cypress.io/guides/using-aliases)
|
||||
**Note:** `.as()` assumes you are already familiar with core concepts such as {% url 'aliases' aliases %}
|
||||
{% endnote %}
|
||||
|
||||
# Syntax
|
||||
@@ -91,10 +91,10 @@ cy
|
||||
|
||||
Aliases of routes display in the routes instrument panel:
|
||||
|
||||
<img width="567" alt="screen shot 2015-11-29 at 2 25 47 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459470/22e31e54-96a5-11e5-8895-a6ff5f8bb973.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- {% url `cy.get()` get %}
|
||||
- [Using Aliases](https://on.cypress.io/guides/using-aliases)
|
||||
- {% url 'Aliases' aliases %}
|
||||
- {% url `cy.wait()` wait %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: blur
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make a focused DOM element blur.
|
||||
@@ -85,11 +85,11 @@ cy.get('[name="comment"]').focus().type('Nice Product!').blur()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="524" alt="screen shot 2015-11-27 at 1 37 36 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446921/58a14e34-950c-11e5-85ba-633b7ed5d7f1.png">
|
||||

|
||||
|
||||
When clicking on the `blur` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="525" alt="screen shot 2015-11-27 at 1 37 53 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446923/5c44a2ca-950c-11e5-8080-0dc108bc4959.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: check
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Check checkbox(es) or radio(s).
|
||||
@@ -122,11 +122,11 @@ cy.get('form').find('[name="emailUser"]').check()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="582" alt="screen shot 2015-11-29 at 12 53 25 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458925/6226b39e-9698-11e5-9a2a-debf91f5989a.png">
|
||||

|
||||
|
||||
When clicking on `check` within the command log, the console outputs the following:
|
||||
|
||||
<img width="547" alt="screen shot 2015-11-29 at 12 53 48 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458927/65a2526c-9698-11e5-8b33-f59e666170e2.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: children
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the children of each DOM element within a set of DOM elements.
|
||||
@@ -117,11 +117,11 @@ cy.get('.left-nav>.nav').children().should('have.length', 8)
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="521" alt="screen shot 2015-11-27 at 1 52 26 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447069/2b0f8a7e-950e-11e5-96b5-9d82d9fdddec.png">
|
||||

|
||||
|
||||
When clicking on the `children` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="542" alt="screen shot 2015-11-27 at 1 52 41 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447071/2e9252bc-950e-11e5-9a32-e5860da89160.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clear
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear the value of an `input` or `textarea`.
|
||||
@@ -79,11 +79,11 @@ cy.get('input[name="name"]').clear().type('Jane Lane')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="570" alt="screen shot 2015-11-29 at 12 56 58 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458939/bac1f4dc-9698-11e5-8e20-1ed9405f3d30.png">
|
||||

|
||||
|
||||
When clicking on `clear` within the command log, the console outputs the following:
|
||||
|
||||
<img width="511" alt="screen shot 2015-11-29 at 12 57 07 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458940/bdc93a50-9698-11e5-8be7-ef6a0470c3ae.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clearCookie
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear a browser cookie.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clearCookies
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear all browser cookies.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clearLocalStorage
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear all data in local storage.
|
||||
@@ -76,11 +76,11 @@ cy.clearLocalStorage(/prop1|2/).then(function(ls){
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="466" alt="screen shot 2017-05-24 at 3 19 15 pm" src="https://cloud.githubusercontent.com/assets/1271364/26421551/738be792-4094-11e7-9100-14937a369c7c.png">
|
||||

|
||||
|
||||
When clicking on `clearLocalStorage` within the command log, the console outputs the following:
|
||||
|
||||
<img width="564" alt="screen shot 2017-05-24 at 3 19 25 pm" src="https://cloud.githubusercontent.com/assets/1271364/26421552/73b17ac0-4094-11e7-8a13-b59bc9613613.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: click
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Click a DOM element.
|
||||
@@ -129,7 +129,7 @@ cy.get('button').click(5, 60, { force: true })
|
||||
**Hover and clicking hidden elements**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe on testing hover and working with hidden elements.](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/hover_hidden_elements_spec.js)
|
||||
{% url 'Check out our example recipe on testing hover and working with hidden elements.' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/hover_hidden_elements_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
**Click all buttons found on the page**
|
||||
@@ -152,9 +152,9 @@ cy.get('button').click()
|
||||
|
||||
The events are fired to spec, including the coordinates of where the event took place.
|
||||
|
||||
At the moment, `mouseover` and `mouseout` events are *not* fired. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
At the moment, `mouseover` and `mouseout` events are *not* fired. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
Additionally if the `mousedown` event causes the element to be removed from the DOM, the remaining events should continue to be fired, but to the resulting element left below the removed element. This has also not been implemented. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
Additionally if the `mousedown` event causes the element to be removed from the DOM, the remaining events should continue to be fired, but to the resulting element left below the removed element. This has also not been implemented. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
**Focus is given to the first focusable element**
|
||||
|
||||
@@ -172,11 +172,11 @@ The coordinates of the click will be recorded the exact moment the click happens
|
||||
|
||||
**pointer-events: none**
|
||||
|
||||
Cypress does not currently factor in `pointer-events: none` in its clicking algorithm. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
Cypress does not currently factor in `pointer-events: none` in its clicking algorithm. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
**Element removal during `mousedown` or `mouseup`**
|
||||
|
||||
The spec states what should happen if the element clicked is removed from the DOM during `mousedown` or `mouseup`, but Cypress is not currently factoring this in. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
The spec states what should happen if the element clicked is removed from the DOM during `mousedown` or `mouseup`, but Cypress is not currently factoring this in. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
**Animations**
|
||||
|
||||
@@ -198,11 +198,11 @@ cy.get('form').find('button').contains('Create User').click()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="590" alt="screen shot 2015-11-29 at 1 07 27 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458988/3cd5bae8-969a-11e5-9938-40a553402992.png">
|
||||

|
||||
|
||||
When clicking on `click` within the command log, the console outputs the following:
|
||||
|
||||
<img width="759" alt="screen shot 2015-11-29 at 1 07 49 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458989/4036493c-969a-11e5-8f98-377dfce1f2c1.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clock
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`cy.clock()` overrides native global functions related to time allowing them to be controlled synchronously via {% url `cy.tick()` tick %} or the yielded `clock` object. This includes controlling:
|
||||
@@ -172,7 +172,7 @@ cy.clock(null, ['setTimeout', 'clearTimeout'])
|
||||
**Using cy.clock() and cy.tick()**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe testing spying, stubbing and time.](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/spy_stub_clock_spec.js)
|
||||
{% url 'Check out our example recipe testing spying, stubbing and time.' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/spy_stub_clock_spec.js%}
|
||||
{% endnote %}
|
||||
|
||||
# Notes
|
||||
@@ -196,16 +196,16 @@ cy.tick(1000)
|
||||
|
||||
The command above will display in the command log as:
|
||||
|
||||
<img width="448" alt="screen shot of command log" src="https://cloud.githubusercontent.com/assets/1157043/22437918/059f60a6-e6f8-11e6-903d-d868e044615d.png">
|
||||

|
||||
|
||||
When clicking on the `clock` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="1059" alt="screen shot of console output" src="https://cloud.githubusercontent.com/assets/1157043/22437920/0786f9d8-e6f8-11e6-9e77-926b15aa8dae.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- {% url 'Guide: Stubs, Spies and Clocks' stubs-spies-clocks %}
|
||||
- {% url `cy.spy()` spy %}
|
||||
- {% url `cy.stub()` stub %}
|
||||
- [Recipe: Controlling Behavior with Spies, Stubs, and Clocks](https://github.com/cypress-io/cypress-example-recipes#controlling-behavior-with-spies-stubs-and-clocks)
|
||||
- {% url 'Recipe: Controlling Behavior with Spies, Stubs, and Clocks' https://github.com/cypress-io/cypress-example-recipes %}
|
||||
- {% url `cy.tick()` tick %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: closest
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the first DOM element that matches the selector (whether it be itself or one of it's ancestors).
|
||||
@@ -72,11 +72,11 @@ cy.get('li.active').closest('.nav')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="530" alt="screen shot 2015-11-27 at 2 07 28 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447200/500fe9ca-9510-11e5-8c77-8afb8325d937.png">
|
||||

|
||||
|
||||
When clicking on the `closest` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="478" alt="screen shot 2015-11-27 at 2 07 46 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447201/535515c4-9510-11e5-9cf5-088bf21f34ac.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: contains
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the DOM element containing the text. DOM elements can contain *more* than the desired text and still match. Additionally, Cypress [prefers some DOM elements](#Notes) over the deepest element found.
|
||||
@@ -318,11 +318,11 @@ cy.get('h1').contains('New User')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="536" alt="screen shot 2015-11-27 at 1 43 22 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446973/009ac32c-950d-11e5-9eaa-09f8b8ddf086.png">
|
||||

|
||||
|
||||
When clicking on the `contains` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="477" alt="screen shot 2015-11-27 at 1 43 50 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446977/04b31be4-950d-11e5-811e-4fd83d364d00.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: dblclick
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Double-click a DOM element.
|
||||
@@ -69,11 +69,11 @@ cy.get('[data-schedule-id="4529114"]:first').dblclick()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="585" alt="screen shot 2015-11-29 at 1 12 02 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459013/035a6c5e-969b-11e5-935f-dce5c8efbdd6.png">
|
||||

|
||||
|
||||
When clicking on `dblclick` within the command log, the console outputs the following:
|
||||
|
||||
<img width="836" alt="screen shot 2015-11-29 at 1 12 26 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459015/0755e216-969b-11e5-9f7e-ed04245d75ef.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: debug
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Set a `debugger` and log what the previous command yields.
|
||||
@@ -63,15 +63,15 @@ cy.get(".ls-btn").click({ force: true }).debug()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="466" alt="screen shot 2017-05-24 at 4 10 23 pm" src="https://cloud.githubusercontent.com/assets/1271364/26423391/896b858e-409b-11e7-91ce-14c5bf38ab11.png">
|
||||

|
||||
|
||||
When clicking on the `debug` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="572" alt="screen shot 2017-05-24 at 4 10 08 pm" src="https://cloud.githubusercontent.com/assets/1271364/26423392/89725486-409b-11e7-94d5-aebdffe16abf.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- [Cypress Dashboard](https://on.cypress.io/dashboard)
|
||||
- {% url 'Dashboard' https://on.cypress.io/dashboard %}
|
||||
- {% url `.pause()` pause %}
|
||||
- {% url `cy.log()` log %}
|
||||
- {% url `cy.screenshot()` screenshot %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: document
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the document.
|
||||
@@ -68,11 +68,11 @@ cy.document()
|
||||
|
||||
The command above will display in the command log as:
|
||||
|
||||
<img width="588" alt="screen shot 2015-11-29 at 2 00 09 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459311/aab8fe88-96a1-11e5-9b72-b0501204030d.png">
|
||||

|
||||
|
||||
When clicking on `document` within the command log, the console outputs the following:
|
||||
|
||||
<img width="491" alt="screen shot 2015-11-29 at 2 00 22 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459314/ad27d7e8-96a1-11e5-8d1c-9c4ede6c54aa.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: each
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Iterate through an array like structure (arrays or objects with a `length` property).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: end
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
End a chain of commands.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: eq
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get A DOM element at a specific index in an array of elements.
|
||||
@@ -107,11 +107,11 @@ cy.get('.left-nav.nav').find('>li').eq(3)
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="532" alt="screen shot 2015-11-27 at 2 11 47 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447231/e225e1f2-9510-11e5-8615-4a5b42ef71c1.png">
|
||||

|
||||
|
||||
When clicking on the `eq` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="569" alt="screen shot 2015-11-27 at 2 12 03 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447234/e594ce52-9510-11e5-8794-712a7dbeae55.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: exec
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Execute a system command.
|
||||
@@ -150,11 +150,11 @@ cy.exec('cat cypress.json')
|
||||
|
||||
The command above will display in the command log as:
|
||||
|
||||
<img width="445" alt="screen shot of command log" src="https://cloud.githubusercontent.com/assets/1157043/15369507/e03a7eca-1d00-11e6-8558-396d8c9b6d98.png">
|
||||

|
||||
|
||||
When clicking on the `exec` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="758" alt="screen shot of console output" src="https://cloud.githubusercontent.com/assets/1157043/15969867/e3ab646e-2eff-11e6-9199-987ca2f74025.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: filter
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the DOM elements that match a specific selector.
|
||||
@@ -87,11 +87,11 @@ cy.get('.left-nav>.nav').find('>li').filter('.active')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="522" alt="screen shot 2015-11-27 at 2 15 53 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447263/7176e824-9511-11e5-93cc-fa10b3b94482.png">
|
||||

|
||||
|
||||
When clicking on the `filter` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="503" alt="screen shot 2015-11-27 at 2 16 09 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447266/74b643a4-9511-11e5-8b42-6f6dfbdfb2a8.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: find
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the descendent DOM elements of a specific selector.
|
||||
@@ -80,11 +80,11 @@ cy.get('.left-nav>.nav').find('>li')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="522" alt="screen shot 2015-11-27 at 2 19 38 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447309/f6a9be4a-9511-11e5-84a5-a111215bf1e6.png">
|
||||

|
||||
|
||||
When clicking on the `find` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="516" alt="screen shot 2015-11-27 at 2 19 54 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447312/fa3679cc-9511-11e5-9bea-904f8c70063d.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: first
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the first DOM element within a set of DOM elements.
|
||||
@@ -78,11 +78,11 @@ cy.get('form').find('input').first()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="527" alt="screen shot 2015-11-29 at 12 28 08 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458770/d9439ee6-9694-11e5-8754-b2641ba44883.png">
|
||||

|
||||
|
||||
When clicking on `first` within the command log, the console outputs the following:
|
||||
|
||||
<img width="616" alt="screen shot 2015-11-29 at 12 28 23 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458771/db8cb516-9694-11e5-86c2-cf3bbb9a666d.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
---
|
||||
title: fixture
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Load a fixed set of data located in a file.
|
||||
|
||||
{% note info %}
|
||||
**Note:** `cy.fixture()` assumes you are already familiar with core concepts such as [fixtures](https://on.cypress.io/guides/creating-fixtures)
|
||||
{% endnote %}
|
||||
|
||||
# Syntax
|
||||
|
||||
```javascript
|
||||
@@ -145,7 +141,7 @@ cy
|
||||
**Using fixtures to bootstrap data**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe using cy.fixture to bootstrap data for our application.](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/bootstrapping_app_test_data_spec.js)
|
||||
{% url 'Check out our example recipe using cy.fixture to bootstrap data for our application.' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/bootstrapping_app_test_data_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
**Using an alias to access a fixture**
|
||||
@@ -225,8 +221,7 @@ For other types of files, they will be read as `utf8` by default, unless specifi
|
||||
|
||||
# See also
|
||||
|
||||
- [Guide: Creating Fixtures](https://on.cypress.io/guides/creating-fixtures)
|
||||
- {% url `cy.readFile()` readfile %}
|
||||
- [Recipe: Bootstrapping App Test Data](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/bootstrapping_app_test_data_spec.js)
|
||||
- {% url 'Recipe: Bootstrapping App Test Data' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/bootstrapping_app_test_data_spec.js%}
|
||||
- {% url `cy.route()` route %}
|
||||
- {% url `.then()` then %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: focus
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Focus on a DOM element.
|
||||
@@ -72,7 +72,7 @@ If there is currently a different DOM element with focus, Cypress issues a `blur
|
||||
|
||||
**Can only be called on a valid focusable element.**
|
||||
|
||||
Ensure the element you are trying to call `.focus()` on is a [focusable element](https://www.w3.org/TR/html5/editing.html#focusable). Most commonly, you'll want to ensure that the element is not disabled, although there are [other factors](https://www.w3.org/TR/html5/editing.html#focusable).
|
||||
Ensure the element you are trying to call `.focus()` on is a {% url 'focusable element' https://www.w3.org/TR/html5/editing.html#focusable%}. Most commonly, you'll want to ensure that the element is not disabled, although there are {% url 'other factors' https://www.w3.org/TR/html5/editing.html#focusable%}.
|
||||
|
||||
**Can time out because your browser did not receive any focus events.**
|
||||
|
||||
@@ -88,11 +88,11 @@ cy.get('[name="comment"]').focus()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="524" alt="screen shot 2015-11-27 at 1 32 37 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446856/6c2c36f4-950b-11e5-89c6-9bf14a448b23.png">
|
||||

|
||||
|
||||
When clicking on the `focus` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="526" alt="screen shot 2015-11-27 at 1 33 00 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446857/703fa6c2-950b-11e5-9686-ce6b558cfd92.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: focused
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the DOM element that is currently focused.
|
||||
@@ -74,11 +74,11 @@ cy.focused().should('have.attr', 'name').and('eq', 'num')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="523" alt="screen shot 2015-11-27 at 1 01 51 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446780/f71fb350-9509-11e5-963a-a6940fbc63b6.png">
|
||||

|
||||
|
||||
When clicking on the `focused` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="407" alt="screen shot 2015-11-27 at 1 02 02 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446771/d104a6d0-9509-11e5-9464-2e397cb1eb24.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
title: get
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get one or more DOM elements by selector or [alias](https://on.cypress.io/guides/using-aliases).
|
||||
Get one or more DOM elements by selector or {% url 'alias' aliases %}.
|
||||
|
||||
# Syntax
|
||||
|
||||
@@ -37,7 +37,7 @@ An alias as defined using the {% url `.as()` as %} command and referenced with t
|
||||
Internally, Cypress keeps a cache of all aliased elements. If the element currently exists in the DOM, it is immediately returned. If the element no longer exists, Cypress will re-query the element based on the previous selector path defined before {% url `.as()` as %} to find it again.
|
||||
|
||||
{% note info %}
|
||||
[Read about using aliases here.](https://on.cypress.io/guides/using-aliases)
|
||||
{% url 'Read more about aliases here' aliases %}
|
||||
{% endnote %}
|
||||
|
||||
**{% fa fa-angle-right %} options** ***(Object)***
|
||||
@@ -94,7 +94,7 @@ cy.get('form').within(function(){
|
||||
|
||||
## Alias
|
||||
|
||||
For a detailed explanation of aliasing, [read more about aliasing here](https://on.cypress.io/guides/using-aliases).
|
||||
For a detailed explanation of aliasing, {% url 'read more about aliasing here' aliases %}.
|
||||
|
||||
**Get the aliased 'todos' elements**
|
||||
|
||||
@@ -129,11 +129,11 @@ cy.get('input[name="firstName"]').should('have.value', 'Homer')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="524" alt="screen shot 2015-11-27 at 1 24 20 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446808/5d2f2180-950a-11e5-8645-4f0f14321f86.png">
|
||||

|
||||
|
||||
When clicking on the `get` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="543" alt="screen shot 2015-11-27 at 1 24 45 pm" src="https://cloud.githubusercontent.com/assets/1271364/11446809/61a6f4f4-950a-11e5-9b23-a9efa1fbccfc.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: getCookie
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get a browser cookie by it's name.
|
||||
@@ -72,7 +72,7 @@ cy.getCookie('session_id')
|
||||
**Using `cy.getCookie()` to test logging in**
|
||||
|
||||
{% note info %}
|
||||
Check out our example recipes using `cy.getCookie()` to test [logging in using HTML web forms](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_html_web_form_spec.js), [logging in using XHR web forms](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js) and [logging in with single sign on](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_single_sign_on_spec.js)
|
||||
Check out our example recipes using `cy.getCookie()` to test {% url 'logging in using HTML web forms' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_html_web_form_spec.js %}, {% url 'logging in using XHR web forms' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js %} and {% url 'logging in with single sign on' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_single_sign_on_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
# Command Log
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: getCookies
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all of the browser cookies.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: go
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Navigate back or forward to the previous or next URL in the browser's history.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: hash
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the current URL hash.
|
||||
@@ -80,11 +80,11 @@ cy.hash().should('eq', '#users/new')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="581" alt="screen shot 2015-11-29 at 1 34 12 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459152/ed737be4-969d-11e5-823e-1d12cd7d03b1.png">
|
||||

|
||||
|
||||
When clicking on `hash` within the command log, the console outputs the following:
|
||||
|
||||
<img width="472" alt="screen shot 2015-11-29 at 1 34 17 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459153/f0aa6476-969d-11e5-9851-302957f9eb0f.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
title: hover
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
{% note danger %}
|
||||
Cypress does not have a **cy.hover()** command. See [Issue #10](https://github.com/cypress-io/cypress/issues/10).
|
||||
Cypress does not have a **cy.hover()** command. See {% issue 10 'Issue #10' %}.
|
||||
{% endnote %}
|
||||
|
||||
If `cy.hover()` is used, an error will display and redirect you to this page.
|
||||
@@ -23,7 +23,7 @@ cy.get('.content').invoke('show').click()
|
||||
```
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe on testing hover and working with hidden elements](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/hover_hidden_elements_spec.js)
|
||||
{% url 'Check out our example recipe on testing hover and working with hidden elements' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/hover_hidden_elements_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
You can also force the action to be performed on the element regardless of whether the element is visible or not.
|
||||
@@ -52,5 +52,5 @@ cy.get('.content').trigger('mouseover')
|
||||
# See also
|
||||
|
||||
- {% url `.invoke()` invoke %}
|
||||
- [Recipe: Dealing with Hover and Hidden Elements](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/hover_hidden_elements_spec.js)
|
||||
- {% url 'Recipe: Dealing with Hover and Hidden Elements' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/hover_hidden_elements_spec.js %}
|
||||
- {% url `cy.wrap()` wrap %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: invoke
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Invoke a function on the previously yielded subject.
|
||||
@@ -152,11 +152,11 @@ cy.get('.connectors-div').should('be.hidden')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="470" alt="screen shot 2017-06-01 at 1 13 44 pm" src="https://cloud.githubusercontent.com/assets/1271364/26691729/3a75b3c8-46cc-11e7-835d-68200388ddf2.png">
|
||||

|
||||
|
||||
When clicking on `invoke` within the command log, the console outputs the following:
|
||||
|
||||
<img width="534" alt="screen shot 2017-06-01 at 1 14 00 pm" src="https://cloud.githubusercontent.com/assets/1271364/26691730/3a9baeca-46cc-11e7-8519-9e4a04490601.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: its
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get a property on the previously yielded subject.
|
||||
@@ -117,7 +117,7 @@ cy
|
||||
**Use `.its()` to test `window.fetch`**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe on testing `window.fetch` using `.its()`](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/spy_stub_clock_spec.js)
|
||||
{% url 'Check out our example recipe on testing `window.fetch` using `.its()`' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/spy_stub_clock_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
## Nested Properties
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: last
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the last DOM element within a set of DOM elements.
|
||||
@@ -78,11 +78,11 @@ cy.get('form').find('button').last()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="560" alt="screen shot 2015-11-29 at 12 33 52 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458797/8e9abdf6-9695-11e5-8594-7044751d5199.png">
|
||||

|
||||
|
||||
When clicking on `last` within the command log, the console outputs the following:
|
||||
|
||||
<img width="746" alt="screen shot 2015-11-29 at 12 34 07 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458799/91a115cc-9695-11e5-8569-93fbaa2704d4.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: location
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the remote `window.location` as an object.
|
||||
@@ -115,7 +115,7 @@ cy.window().then(function(window){
|
||||
})
|
||||
```
|
||||
|
||||
<img width="422" alt="screen shot 2017-05-26 at 11 41 27 am" src="https://cloud.githubusercontent.com/assets/1271364/26501744/6f9b6188-4208-11e7-91ce-59dbb455b1fc.png">
|
||||

|
||||
|
||||
***Console output of `.location()`***
|
||||
|
||||
@@ -125,7 +125,7 @@ cy.location().then(function(location){
|
||||
})
|
||||
```
|
||||
|
||||
<img width="478" alt="screen shot 2017-05-26 at 11 42 11 am" src="https://cloud.githubusercontent.com/assets/1271364/26501743/6f8fcb84-4208-11e7-9f08-9c97592afc08.png">
|
||||

|
||||
|
||||
# Command Log
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: log
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Print a message to the Cypress Command Log.
|
||||
@@ -69,11 +69,11 @@ cy.log('another message', ['one', 'two', 'three'])
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="560" alt="command log with cy.log" src="https://cloud.githubusercontent.com/assets/1271364/21321329/55389b3c-c5e2-11e6-8607-592683d520da.png">
|
||||

|
||||
|
||||
When clicking on `log` within the command log, the console outputs the following:
|
||||
|
||||
<img width="746" alt="console display of cy.log" src="https://cloud.githubusercontent.com/assets/1271364/21321324/4f616dec-c5e2-11e6-8c2f-924e7bfd6f87.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: next
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the immediately following sibling of each DOM element within a set of DOM elements.
|
||||
@@ -101,11 +101,11 @@ cy.get('.left-nav').find('li.active').next()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="563" alt="screen shot 2015-11-29 at 12 42 07 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458857/afcfddf2-9696-11e5-9405-0cd994f70d45.png">
|
||||

|
||||
|
||||
When clicking on `next` within the command log, the console outputs the following:
|
||||
|
||||
<img width="547" alt="screen shot 2015-11-29 at 12 42 22 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458858/b30b0a0a-9696-11e5-99b9-d785b597287c.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: nextAll
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all following siblings of each DOM element in a set of matched DOM elements.
|
||||
@@ -104,11 +104,11 @@ cy.get('.left-nav').find('li.active').nextAll()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="560" alt="screen shot 2017-03-23 at 2 05 32 pm" src="https://cloud.githubusercontent.com/assets/1271364/24262886/e1513334-0fd1-11e7-93b1-b413a9390828.png">
|
||||

|
||||
|
||||
When clicking on `nextAll` within the command log, the console outputs the following:
|
||||
|
||||
<img width="567" alt="screen shot 2017-03-23 at 2 05 52 pm" src="https://cloud.githubusercontent.com/assets/1271364/24262907/f2b7fe78-0fd1-11e7-921c-6eabf6e32abb.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: nextUntil
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
|
||||
@@ -103,11 +103,11 @@ cy.get('#veggies').nextUntil('#nuts')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="563" alt="screen shot 2017-03-23 at 2 17 52 pm" src="https://cloud.githubusercontent.com/assets/1271364/24263453/96a8c0b6-0fd3-11e7-8a66-da9177ca94a7.png">
|
||||

|
||||
|
||||
When clicking on `nextUntil` within the command log, the console outputs the following:
|
||||
|
||||
<img width="514" alt="screen shot 2017-03-23 at 2 18 01 pm" src="https://cloud.githubusercontent.com/assets/1271364/24263481/a20ce2f2-0fd3-11e7-881c-f6bf8d652263.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: not
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Filter DOM element(s) from a set of DOM elements.
|
||||
@@ -76,11 +76,11 @@ cy.get('form').find('button').not('[type="submit"]')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="572" alt="screen shot 2015-11-29 at 12 36 49 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458817/0a846c3c-9696-11e5-9901-5f4376629e75.png">
|
||||

|
||||
|
||||
When clicking on `not` within the command log, the console outputs the following:
|
||||
|
||||
<img width="689" alt="screen shot 2015-11-29 at 12 37 39 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458819/0d6870f6-9696-11e5-9364-2685b8ffc71b.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: parent
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the parent DOM element of a set of DOM elements.
|
||||
@@ -82,11 +82,11 @@ cy.get('li.active').parent().should('have.class', 'nav')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="531" alt="screen shot 2015-11-27 at 1 58 32 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447127/0d9ab5a8-950f-11e5-90ae-c317dd83aa65.png">
|
||||

|
||||
|
||||
When clicking on the `parent` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="440" alt="screen shot 2015-11-27 at 1 58 44 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447130/11b22c02-950f-11e5-9b82-cc3b2ff8548e.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: parents
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the parent DOM elements of a set of DOM elements.
|
||||
@@ -81,11 +81,11 @@ cy.get('li.active').parents('.nav')
|
||||
cy.get('li.active').parents()
|
||||
```
|
||||
|
||||
<img width="531" alt="screen shot 2015-11-27 at 2 02 59 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447168/be286244-950f-11e5-82e8-9a2a6d1d08e8.png">
|
||||

|
||||
|
||||
When clicking on the `parents` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="537" alt="screen shot 2015-11-27 at 2 03 32 pm" src="https://cloud.githubusercontent.com/assets/1271364/11447171/c1ba5ef8-950f-11e5-9f2d-7fbd0b142649.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: parentsUntil
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all ancestors of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
|
||||
@@ -101,11 +101,11 @@ cy.get('.active').parentsUntil('.nav')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="561" alt="screen shot 2017-03-23 at 2 37 31 pm" src="https://cloud.githubusercontent.com/assets/1271364/24264301/516d5fd6-0fd6-11e7-9ab7-b55b211acde3.png">
|
||||

|
||||
|
||||
When clicking on `parentsUntil` within the command log, the console outputs the following:
|
||||
|
||||
<img width="523" alt="screen shot 2017-03-23 at 2 37 39 pm" src="https://cloud.githubusercontent.com/assets/1271364/24264309/60cc75de-0fd6-11e7-97b4-d0aa184b0ba6.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: pause
|
||||
comments: true
|
||||
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.
|
||||
@@ -72,37 +72,37 @@ cy.get('#action-canvas')
|
||||
|
||||
The commands above will display in the GUI as:
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 10 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507426/4d48a5e4-421e-11e7-9bd4-c6829f80910d.png">
|
||||

|
||||
|
||||
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"***
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 15 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507427/4d49e33c-421e-11e7-9bea-26b89ec6fe32.png">
|
||||

|
||||
|
||||
***Click "Next" again***
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 24 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507424/4d446204-421e-11e7-82a1-a5ce8b4bb4a9.png">
|
||||

|
||||
|
||||
***Click "Next" again***
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 29 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507421/4d3a69e8-421e-11e7-9a26-1026d0d133ec.png">
|
||||

|
||||
|
||||
***Click "Next" again***
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 33 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507422/4d3b30a8-421e-11e7-940d-bd7bdc7b6e81.png">
|
||||

|
||||
|
||||
***Click "Next" again***
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 36 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507420/4d37dcc8-421e-11e7-8428-8529ad628b05.png">
|
||||

|
||||
|
||||
***Click "Next" again, then 'Resume'***
|
||||
|
||||
<img width="985" alt="screen shot 2017-05-26 at 2 18 51 pm" src="https://cloud.githubusercontent.com/assets/1271364/26507423/4d3c5992-421e-11e7-8df8-9af67f5ceb4a.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- [Cypress Dashboard](https://on.cypress.io/dashboard)
|
||||
- {% url 'Dashboard' https://on.cypress.io/dashboard %}
|
||||
- {% url `cy.debug()` debug %}
|
||||
- {% url `cy.log()` log %}
|
||||
- {% url `cy.screenshot()` screenshot %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: prev
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the immediately preceding sibling of each element in a set of the elements.
|
||||
@@ -104,11 +104,11 @@ cy.get('.left-nav').find('li.active').prev()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="564" alt="screen shot 2015-11-29 at 12 46 57 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458884/5bb4da1e-9697-11e5-9172-762df10c9a6e.png">
|
||||

|
||||
|
||||
When clicking on `prev` within the command log, the console outputs the following:
|
||||
|
||||
<img width="446" alt="screen shot 2015-11-29 at 12 47 09 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458886/5e20c63c-9697-11e5-9167-1b81f96e1906.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: prevAll
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all previous siblings of each DOM element in a set of matched DOM elements.
|
||||
@@ -104,11 +104,11 @@ cy.get('.left-nav').find('li.active').prevAll()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="562" alt="screen shot 2017-03-23 at 2 50 20 pm" src="https://cloud.githubusercontent.com/assets/1271364/24264885/1a1d87ac-0fd8-11e7-97cb-1d0d2110de81.png">
|
||||

|
||||
|
||||
When clicking on `prevAll` within the command log, the console outputs the following:
|
||||
|
||||
<img width="539" alt="screen shot 2017-03-23 at 2 50 26 pm" src="https://cloud.githubusercontent.com/assets/1271364/24264898/2219d1a4-0fd8-11e7-9e8b-6b2d97166d6a.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: prevUntil
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
|
||||
@@ -102,11 +102,11 @@ cy.get('#nuts').prevUntil('#veggies')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="560" alt="screen shot 2017-03-23 at 2 45 30 pm" src="https://cloud.githubusercontent.com/assets/1271364/24264621/69ed829c-0fd7-11e7-934d-c11157c36aca.png">
|
||||

|
||||
|
||||
When clicking on `prevUntil` within the command log, the console outputs the following:
|
||||
|
||||
<img width="560" alt="screen shot 2017-03-23 at 2 45 36 pm" src="https://cloud.githubusercontent.com/assets/1271364/24264632/7743f57a-0fd7-11e7-99f8-c148acd17459.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: readFile
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Read a file and yield its contents.
|
||||
@@ -162,15 +162,14 @@ cy.readFile('cypress.json')
|
||||
|
||||
The command above will display in the command log as:
|
||||
|
||||
<img width="521" alt="screen shot of command log" src="https://cloud.githubusercontent.com/assets/1157043/17934353/a02d6c34-69e5-11e6-8f1d-ab1eda17ab3b.png">
|
||||

|
||||
|
||||
When clicking on the `readFile` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="689" alt="screen shot of console output" src="https://cloud.githubusercontent.com/assets/1157043/17934460/089e0652-69e6-11e6-9f00-7eb282be0d27.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- [Creating Fixtures](https://on.cypress.io/guides/creating-fixtures)
|
||||
- {% url `cy.exec()` exec %}
|
||||
- {% url `cy.fixture()` fixture %}
|
||||
- {% url `cy.writeFile()` writefile %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: reload
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Reload the page.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: request
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make an HTTP request.
|
||||
@@ -184,7 +184,7 @@ cy.getCookie('cypress-session-cookie').should('exist')
|
||||
**Using cy.request for HTML Forms**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe using cy.request for HTML form submissions](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_html_web_form_spec.js)
|
||||
{% url 'Check out our example recipe using `cy.request` for HTML form submissions' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_html_web_form_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
# Notes
|
||||
@@ -212,8 +212,8 @@ In other words, `cy.request()` transparently performs all of the underlying func
|
||||
# See also
|
||||
|
||||
- {% url `cy.exec()` exec %}
|
||||
- [Recipe: Logging In - CSRF Tokens](https://github.com/cypress-io/cypress-example-recipes#logging-in---csrf-tokens)
|
||||
- [Recipe: Logging In - HTML Web Form](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_html_web_form_spec.js)
|
||||
- [Recipe: Logging In - Single Sign on](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_single_sign_on_spec.js)
|
||||
- [Recipe: Logging In - XHR Web Form](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js)
|
||||
- {% url 'Recipe: Logging In - CSRF Tokens' https://github.com/cypress-io/cypress-example-recipes %}
|
||||
- {% url 'Recipe: Logging In - HTML Web Form' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_html_web_form_spec.js %}
|
||||
- {% url 'Recipe: Logging In - Single Sign on' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_single_sign_on_spec.js %}
|
||||
- {% url 'Recipe: Logging In - XHR Web Form' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js %}
|
||||
- {% url `cy.visit()` visit %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: root
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the root element.
|
||||
@@ -82,11 +82,11 @@ cy.get('.query-ul').within(function(){
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="471" alt="screen shot 2017-06-05 at 12 37 56 pm" src="https://cloud.githubusercontent.com/assets/1271364/26793399/ddafd970-49eb-11e7-9267-c35b583bb76f.png">
|
||||

|
||||
|
||||
When clicking on the `root` command within the command log, the console outputs the following:
|
||||
|
||||
<img width="394" alt="screen shot 2017-06-05 at 12 38 02 pm" src="https://cloud.githubusercontent.com/assets/1271364/26793398/dda22da2-49eb-11e7-98e8-5cd381aac175.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: route
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Use `cy.route` to manage the behavior of network requests.
|
||||
|
||||
{% note info %}
|
||||
**Note:** `cy.route()` assumes you are already familiar with core concepts such as [network requests](https://on.cypress.io/guides/network-requests-xhr)
|
||||
**Note:** `cy.route()` assumes you are already familiar with core concepts such as {% url 'network requests' network-requests %}
|
||||
{% endnote %}
|
||||
|
||||
# Syntax
|
||||
@@ -99,12 +99,12 @@ cy.wait('@postUser')
|
||||
**Setup route to `POST` to login**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe using `cy.route()` to POST for login](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js)
|
||||
{% url 'Check out our example recipe using `cy.route()` to POST for login' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
**Wait on `url` matching glob**
|
||||
|
||||
Under the hood Cypress uses [minimatch](https://github.com/isaacs/minimatch) to match glob patterns of `url`.
|
||||
Under the hood Cypress uses {% url 'minimatch' https://github.com/isaacs/minimatch %} to match glob patterns of `url`.
|
||||
|
||||
This means you can take advantage of `*` and `**` glob support. This makes it *much* easier to route against dynamic segments without having to build up a complex `RegExp`.
|
||||
|
||||
@@ -133,7 +133,7 @@ cy.route('/posts/**')
|
||||
|
||||
**Override `url` glob matching options**
|
||||
|
||||
When we check `glob` patterns with [minimatch](https://github.com/isaacs/minimatch), by default Cypress uses sets `matchBase` to `true`. You can override this option in {% url `cy.server()` server %} options.
|
||||
When we check `glob` patterns with {% url 'minimatch' https://github.com/isaacs/minimatch %}, by default Cypress uses sets `matchBase` to `true`. You can override this option in {% url `cy.server()` server %} options.
|
||||
|
||||
If you want to permanently override these options you could do so by setting {% url `Cypress.Server.defaults()` cypress-server %}.
|
||||
|
||||
@@ -194,7 +194,7 @@ cy.route('POST', '/comments/**', commentsResponse)
|
||||
|
||||
Any request that matches the `method` and `url` of a route will be responded to based on the configuration of that route.
|
||||
|
||||
If a request doesn't match any route, [it will automatically receive a 404](#notes). For example, given we have the following routes:
|
||||
If a request doesn't match any route, [it will automatically receive a 404](#Notes). For example, given we have the following routes:
|
||||
|
||||
```javascript
|
||||
cy.server()
|
||||
@@ -315,7 +315,7 @@ cy.route({
|
||||
**Setup route to error on POST to login**
|
||||
|
||||
{% note info %}
|
||||
[Check out our example recipe using cy.route to simulate a 503 on POST to login](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js)
|
||||
{% url 'Check out our example recipe using `cy.route()` to simulate a 503 on POST to login' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js %}
|
||||
{% endnote %}
|
||||
|
||||
**Change `headers`**
|
||||
@@ -461,7 +461,7 @@ When clicking on `XHR Stub` within the Command Log, the console outputs the foll
|
||||
|
||||
- {% url `.as()` as %}
|
||||
- {% url `cy.fixture()` fixture %}
|
||||
- [Guide: Network Requests](https://on.cypress.io/guides/network-requests-xhr)
|
||||
- [Recipe: Loggin in - XHR Web Form](https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js)
|
||||
- {% url 'Network Requests' network-requests %}
|
||||
- {% url 'Recipe: Logging in - XHR Web Form' https://github.com/cypress-io/cypress-example-recipes/blob/master/cypress/integration/logging_in_xhr_web_form_spec.js %}
|
||||
- {% url `cy.server()` server %}
|
||||
- {% url `cy.wait()` wait %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: screenshot
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Take a screenshot of the application under test and the Cypress Command Log.
|
||||
@@ -83,17 +83,17 @@ When running headlessly or in {% url 'Continuous Integration' continuous-integra
|
||||
|
||||
**Screenshots in CI**
|
||||
|
||||
You can see screenshots taken during a CI run in the [Cypress Dashboard](https://on.cypress.io/dashboard) without any extra work.
|
||||
You can see screenshots taken during a CI run in the {% url 'Dashboard' https://on.cypress.io/dashboard %} without any extra work.
|
||||
|
||||
Alternatively, to see screenshots in the [Circle CI](https://circleci.com/) UI, we automatically export screenshots as artifacts. This makes them available directly in their web UI.
|
||||
Alternatively, to see screenshots in the {% url 'Circle CI' https://circleci.com/ %} UI, we automatically export screenshots as artifacts. This makes them available directly in their web UI.
|
||||
|
||||
If you're using Travis, you'll need to upload artifacts to an s3 bucket as per their [uploading artifacts doc](https://docs.travis-ci.com/user/uploading-artifacts/) to see screenshots outside of the Cypress Dashboard.
|
||||
If you're using Travis, you'll need to upload artifacts to an s3 bucket as per their {% url 'uploading artifacts doc' https://docs.travis-ci.com/user/uploading-artifacts/ %} to see screenshots outside of the Cypress Dashboard.
|
||||
|
||||
**Understanding when a screenshot happens**
|
||||
|
||||
Taking a screenshot is an asynchronous action that takes around `100ms` to complete. By the time the screenshot is taken, it's possible something in your application may have changed. It's important to realize that the screenshot may not reflect 100% of what your application looked like when the command was issued.
|
||||
|
||||
For example - say a command we wrote times outs: `cy.get('#element')`. This causes your test to fail. Cypress then takes a screenshot when the test fails, but it's possible something in your application changed within the `100ms` timeframe. Hypothetically your app could render the element you were searching for. When this happens the screenshot may provide confusing results. It's unlikely, but theoretically possible.
|
||||
For example - say a command we wrote times outs: {% url '`cy.get('#element')`' get %}. This causes your test to fail. Cypress then takes a screenshot when the test fails, but it's possible something in your application changed within the `100ms` timeframe. Hypothetically your app could render the element you were searching for. When this happens the screenshot may provide confusing results. It's unlikely, but theoretically possible.
|
||||
|
||||
# Command Log
|
||||
|
||||
@@ -105,14 +105,14 @@ cy.screenshot('my-image')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="559" alt="screen shot 2016-06-13 at 10 46 25 am" src="https://cloud.githubusercontent.com/assets/1271364/16012082/ded7af6c-3155-11e6-83cb-b0dcb6f850a7.png">
|
||||

|
||||
|
||||
When clicking on `screenshot` within the command log, the console outputs the following:
|
||||
|
||||
<img width="667" alt="screen shot 2016-06-13 at 10 46 15 am" src="https://cloud.githubusercontent.com/assets/1271364/16012081/ded22a2e-3155-11e6-8303-0f1ec64e209b.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- {% url `cy.debug()` debug %}
|
||||
- [Cypress Dashboard](https://on.cypress.io/dashboard)
|
||||
- {% url 'Dashboard' https://on.cypress.io/dashboard %}
|
||||
- {% url `.pause()` pause %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: select
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Select an `<option>` within a `<select>` DOM element.
|
||||
@@ -137,11 +137,11 @@ cy.get('select').select('Homer Simpson')
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="575" alt="screen shot 2015-11-29 at 1 17 27 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459044/a2fd8fca-969b-11e5-8d23-3a118b82b5de.png">
|
||||

|
||||
|
||||
When clicking on `select` within the command log, the console outputs the following:
|
||||
|
||||
<img width="560" alt="screen shot 2015-11-29 at 1 17 45 pm" src="https://cloud.githubusercontent.com/assets/1271364/11459045/a6b3bde2-969b-11e5-9357-272ea9684987.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: server
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Start a server to begin routing responses to `cy.route()` and `cy.request()`.
|
||||
|
||||
{% note info %}
|
||||
**Note:** `cy.server()` assumes you are already familiar with core concepts such as [network requests](https://on.cypress.io/guides/network-requests-xhr)
|
||||
**Note:** `cy.server()` assumes you are already familiar with core concepts such as {% url 'network requests' network-requests %}.
|
||||
{% endnote %}
|
||||
|
||||
|
||||
@@ -228,11 +228,11 @@ When a new test runs, any outstanding requests still in flight are automatically
|
||||
|
||||
Oftentimes your application may make initial requests immediately when it loads (such as authenticating a user). Cypress makes it possible to start your server and define routes before a {% url `cy.visit()` visit %}. Upon the next visit, the server + routes will be instantly applied before your application loads.
|
||||
|
||||
You can [read more about XHR strategy here](https://on.cypress.io/guides/network-requests-xhr).
|
||||
You can {% url 'read more about XHR strategy here' network-requests %}.
|
||||
|
||||
# See also
|
||||
|
||||
- [Network Requests](https://on.cypress.io/guides/network-requests-xhr)
|
||||
- {% url 'Network Requests' network-requests %}
|
||||
- {% url `cy.request()` request %}
|
||||
- {% url `cy.route()` route %}
|
||||
- {% url `cy.visit()` visit %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: setCookie
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Set a browser cookie.
|
||||
@@ -39,7 +39,7 @@ Pass in an options object to change the default behavior of `cy.setCookie()`.
|
||||
Option | Default | Notes
|
||||
--- | --- | ---
|
||||
`domain` | `window.location.hostname` | The domain the cookie is visible to
|
||||
`expiry` | 20 years into the future | When the cookie expires, specified in seconds since [Unix Epoch](https://en.wikipedia.org/wiki/Unix_time).
|
||||
`expiry` | 20 years into the future | When the cookie expires, specified in seconds since {% url 'Unix Epoch' https://en.wikipedia.org/wiki/Unix_time %}.
|
||||
`httpOnly` | `false` | Whether the cookie is an HTTP only cookie
|
||||
`log` | `true` | Whether to display command in Command Log
|
||||
`path` | `/` | The cookie path
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: should
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make an assertion.
|
||||
@@ -10,7 +10,7 @@ An alias of {% url `.and()` and %}
|
||||
{% endnote %}
|
||||
|
||||
{% note info %}
|
||||
**Note:** `.should()` assumes you are already familiar with core concepts such as [assertions](https://on.cypress.io/guides/making-assertions)
|
||||
**Note:** `.should()` assumes you are already familiar with core concepts such as {% url 'assertions' cypress-in-a-nutshell#Assertions %}
|
||||
{% endnote %}
|
||||
|
||||
# Syntax
|
||||
@@ -68,6 +68,7 @@ cy
|
||||
.get('nav') // yields <nav>
|
||||
.should('be.visible') // yields <nav>
|
||||
```
|
||||
|
||||
Although some chainers change what is yielded. In the example below, the second `.should()` yields the String 'sans-serif' because the chainer `have.css, 'font-family'` yields a string.
|
||||
|
||||
```javascript
|
||||
@@ -79,13 +80,25 @@ cy
|
||||
|
||||
## Timeout
|
||||
|
||||
`.should()` will continue to retry the assertion to the duration of the previous cy commands `timeout` or the {% url `defaultCommandTimeout` configuration#Timeouts %}.
|
||||
`.should()` will continue to retry until none of the assertions throw for the duration of the previous cy commands `timeout`.
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should('have.value', '10')
|
||||
↲
|
||||
// timeout here will be passed down to the '.should()'
|
||||
// and it will retry for up to 10 secs
|
||||
// timeout here will be passed down to the '.should()'
|
||||
// and it will retry for up to 10 secs
|
||||
```
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should(function($input)){
|
||||
↲
|
||||
// timeout here will be passed down to the '.should()'
|
||||
// unless an assertion throws earlier,
|
||||
// ALL of the assertions will retry for up to 10 secs
|
||||
expect($input).to.not.be('disabled')
|
||||
expect($input).to.not.have.class('error')
|
||||
expect($input).to.have.value('US')
|
||||
})
|
||||
```
|
||||
|
||||
# Examples
|
||||
@@ -114,10 +127,10 @@ cy.get('option:first').should('be.selected').then(function($option)){
|
||||
cy.get('form').should('have.class', 'form-horizontal')
|
||||
```
|
||||
|
||||
**Assert the value is not 'foo'**
|
||||
**Assert the value is not 'Jane'**
|
||||
|
||||
```javascript
|
||||
cy.get('input').should('not.have.value', 'foo')
|
||||
cy.get('input').should('not.have.value', 'Jane')
|
||||
```
|
||||
|
||||
**The current subject is yielded**
|
||||
@@ -141,7 +154,7 @@ cy.get('#header a').should('have.attr', 'href', '/users')
|
||||
|
||||
**Verify length, content, and classes from multiple `<p>`**
|
||||
|
||||
Passing a function to `.should()` enables you to assert on the yielded subject. This gives you the opportunity to *massage* what you'd like to assert on.
|
||||
Passing a function to `.should()` enables you to make multiple assertions on the yielded subject. This also gives you the opportunity to *massage* what you'd like to assert on.
|
||||
|
||||
Just be sure *not* to include any code that has side effects in your callback function. The callback function will be retried over and over again until no assertions within it throw.
|
||||
|
||||
@@ -191,16 +204,16 @@ Any errors raised by failed assertions will immediately bubble up and cause the
|
||||
```
|
||||
|
||||
```javascript
|
||||
cy.get("#todos li").should(function($lis){
|
||||
cy.get('#todos li').should(function($lis){
|
||||
expect($lis).to.have.length(3)
|
||||
expect($lis.eq(0)).to.contain("Walk the dog")
|
||||
expect($lis.eq(1)).to.contain("Feed the cat")
|
||||
expect($lis.eq(2)).to.contain("Write JavaScript")
|
||||
expect($lis.eq(0)).to.contain('Walk the dog')
|
||||
expect($lis.eq(1)).to.contain('Feed the cat')
|
||||
expect($lis.eq(2)).to.contain('Write JavaScript')
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
**Using a callback function will not change the subject**
|
||||
**Using a callback function will not change what is yielded**
|
||||
|
||||
Whatever is returned in the function is ignored. Cypress always forces the command to yield the value from the previous cy command's yield (which in the example below is `<button>`)
|
||||
|
||||
@@ -250,15 +263,13 @@ cy.get('button').click()
|
||||
.and('not.have.class', 'inactive')
|
||||
```
|
||||
|
||||
You can [read more about how Cypress resolves your assertions](https://on.cypress.io/guides/making-assertions#resolving-assertions) here.
|
||||
|
||||
# Notes
|
||||
|
||||
**How do I know which assertions change the subject and which keep it the same?**
|
||||
|
||||
The chainers that come from {% url 'Chai' bundled-tools#Chai %} or {% url 'Chai-jQuery' bundled-tools#Chai-jQuery %} will always document what they return.
|
||||
|
||||
You can [read more about debugging assertions](https://on.cypress.io/guides/making-assertions#debugging-assertions) here.
|
||||
{% partial then_should_difference %}
|
||||
|
||||
# Command Log
|
||||
|
||||
@@ -270,13 +281,13 @@ cy.get('.left-nav>.nav').children().should('have.length', 8)
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="525" alt="screen shot 2015-11-29 at 12 08 35 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458632/04e5da58-9692-11e5-870d-8f9e274192d1.png">
|
||||

|
||||
|
||||
When clicking on `assert` within the command log, the console outputs the following:
|
||||
|
||||
<img width="768" alt="screen shot 2015-11-29 at 12 08 45 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458633/08a7b238-9692-11e5-9d5d-620122436bc0.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
- {% url `.and()` and %}
|
||||
- [Assertions](https://on.cypress.io/guides/making-assertions)
|
||||
- {% url 'Assertions' cypress-in-a-nutshell#Assertions %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: siblings
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get sibling DOM elements.
|
||||
@@ -94,11 +94,11 @@ cy.get('.left-nav').find('li.active').siblings()
|
||||
|
||||
The commands above will display in the command log as:
|
||||
|
||||
<img width="561" alt="screen shot 2015-11-29 at 12 48 55 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458897/a93f2a1e-9697-11e5-8a5b-b131156e1aa4.png">
|
||||

|
||||
|
||||
When clicking on `siblings` within the command log, the console outputs the following:
|
||||
|
||||
<img width="429" alt="screen shot 2015-11-29 at 12 49 09 pm" src="https://cloud.githubusercontent.com/assets/1271364/11458898/ab940fd2-9697-11e5-96ab-a4c34efa3431.png">
|
||||

|
||||
|
||||
# See also
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: spread
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Expand an array into multiple arguments.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: spy
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Wrap a method in a spy in order to record calls to and arguments of the function.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: stub
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Replace a function, record its usage and control its behavior.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: submit
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Submit a form.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: then
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Yield the previously yielded subject as the first argument of a function.
|
||||
@@ -63,14 +63,14 @@ cy.get('form').find('input').then(function($input){
|
||||
|
||||
## Change subject
|
||||
|
||||
**The subject is changed by returning `{foo: 'bar'}`**
|
||||
**The subject is changed by returning**
|
||||
|
||||
```javascript
|
||||
cy.then(function(){
|
||||
return {foo: 'bar'}
|
||||
return {id: 123}
|
||||
}).then(function(obj){
|
||||
// subject is now the obj {foo: 'bar'}
|
||||
expect(obj).to.deep.eq({foo: 'bar'}) // true
|
||||
// subject is now the obj {id: 123}
|
||||
obj.id === 123 // true
|
||||
})
|
||||
```
|
||||
|
||||
@@ -85,7 +85,7 @@ cy
|
||||
}).find('input').then(function($input){
|
||||
// we have our $input element here since
|
||||
// our form element was yielded and we called
|
||||
// .find("input") on it
|
||||
// .find('input') on it
|
||||
})
|
||||
```
|
||||
|
||||
@@ -129,11 +129,20 @@ cy.get('button').click().then(function($button){
|
||||
})
|
||||
```
|
||||
|
||||
# Notes
|
||||
|
||||
{% partial then_should_difference %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**`cy.then()` does *not* log in the command log**
|
||||
|
||||
# See also
|
||||
|
||||
- {% url `.and()` and %}
|
||||
- {% url `.each()` each %}
|
||||
- {% url `.invoke()` invoke %}
|
||||
- [Issuing Commands](https://on.cypress.io/guides/issuing-commands)
|
||||
- {% url 'Chains of Commands' cypress-in-a-nutshell#Chains-of-Commands %}
|
||||
- {% url `.its()` its %}
|
||||
- {% url `.should()` should %}
|
||||
- {% url `.spread()` spread %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: tick
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Move time after overriding a native time function with {% url `cy.clock()` clock %}.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: title
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the title of the document.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: type
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Type into a DOM element.
|
||||
@@ -274,11 +274,11 @@ cy.get('body').type('{shift}', {release: false}).get('li:first').click()
|
||||
|
||||
**Typing `tab` key does not work**
|
||||
|
||||
Tabbing will be implemented as a separate command as `cy.tab` and support things like multiple tabs, tabbing in reverse, or tabbing to a specific element. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
Tabbing will be implemented as a separate command as `cy.tab` and support things like multiple tabs, tabbing in reverse, or tabbing to a specific element. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
**Preventing `mousedown` does not prevent typing**
|
||||
|
||||
In a real browser, preventing `mousedown` on a form field will prevent it from receiving focus and thus prevent it from being able to be typed into. Currently, Cypress does not factor this in. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
In a real browser, preventing `mousedown` on a form field will prevent it from receiving focus and thus prevent it from being able to be typed into. Currently, Cypress does not factor this in. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
**Modifier effects**
|
||||
|
||||
@@ -300,7 +300,7 @@ In the example above, a lowercase `a` will be typed, because that's the literal
|
||||
|
||||
This holds true for other special key combinations as well (that may be OS-specific). For example, on OSX, typing `ALT + SHIFT + K` creates the special character ``. Like with capitalization, `cy.type()` will not output ``, but simply the letter `k`.
|
||||
|
||||
[Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need modifier effects to be implemented.
|
||||
{% open_an_issue %} if you need modifier effects to be implemented.
|
||||
|
||||
**Events that fire**
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: uncheck
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Uncheck checkbox(es).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: url
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the current URL.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: viewport
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Control the size and orientation of the screen for your application.
|
||||
@@ -141,7 +141,7 @@ cy.viewport('iphone-6', 'landscape')
|
||||
|
||||
**`devicePixelRatio` is not simulated**
|
||||
|
||||
This is something Cypress will eventually do, which will match how Chrome's responsive mobile browsing simulation works. [Open an issue](https://github.com/cypress-io/cypress/issues/new) if you need this to be fixed.
|
||||
This is something Cypress will eventually do, which will match how Chrome's responsive mobile browsing simulation works. {% open_an_issue %} if you need this to be fixed.
|
||||
|
||||
**Cypress will restore the viewport in the snapshot**
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: visit
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Visit a remote url.
|
||||
@@ -26,7 +26,7 @@ cy.visit('http://localhost:3000')
|
||||
|
||||
**{% fa fa-angle-right %} url** ***(String)***
|
||||
|
||||
The url to visit. The url provided will be prefixed with the `baseUrl` configured in your [network options](https://on.cypress.io/guides/configuration#global).
|
||||
The url to visit. The url provided will be prefixed with the `baseUrl` configured in your {% url 'network options' configuration#Global %}.
|
||||
|
||||
**{% fa fa-angle-right %} options** ***(Object)***
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: wait
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Wait for a number of milliseconds or wait for an aliased resource to resolve before moving on to the next command.
|
||||
@@ -38,7 +38,7 @@ The amount of time to wait in milliseconds.
|
||||
An aliased route as defined using the {% url `.as()` as %} command and referenced with the `@` character and the name of the alias.
|
||||
|
||||
{% note info %}
|
||||
[Read about using aliases here.](https://on.cypress.io/guides/using-aliases)
|
||||
{% url 'Read about using aliases here.' aliases %}
|
||||
{% endnote %}
|
||||
|
||||
**{% fa fa-angle-right %} aliases** ***(Array)***
|
||||
@@ -85,7 +85,7 @@ cy.wait(5000) // <--- this is unnecessary
|
||||
|
||||
***Unnecessary wait for `cy.visit()`***
|
||||
|
||||
Waiting for this is unnecessary because the [`cy.visit()`](https://on.cypress.io/visit) resolves once the page fires its `load` event. By that time all of your assets have been loaded including javascript, stylesheets, and html.
|
||||
Waiting for this is unnecessary because the {% url '`cy.visit()`' visit %} resolves once the page fires its `load` event. By that time all of your assets have been loaded including javascript, stylesheets, and html.
|
||||
|
||||
```javascript
|
||||
cy.visit("http://localhost/8080")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: window
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the global `window` object of the remote application that was visited in {% url `cy.visit()` visit %}.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: within
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Set the scope of the containing commands to the previously yielded subject and pass that as an argument to the callback function.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: wrap
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Yield the object passed into `.wrap()`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: writeFile
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Write to a file with the specified contents.
|
||||
@@ -156,4 +156,3 @@ When clicking on the `writeFile` command within the command log, the console out
|
||||
# See also
|
||||
|
||||
- {% url `cy.readFile()` readfile %}
|
||||
- [Creating Fixtures](https://on.cypress.io/guides/creating-fixtures)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress commands
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress comes with its own API for creating custom commands. In fact, the same public methods *you* have access to are the same ones we use to create all of the built in commands. In other words, there's nothing special or different about ours versus yours. You can customize every aspect of commands, not only their behavior, but also their display in the Command Log.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.config
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`get` and `set` configuration options *in your tests*.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Cookies
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`Cookies.debug()`, `Cookies.preserveOnce()` and `Cookies.defaults()` allow you to do more than just get, set, or clear cookies.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Dom
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`Cypress.Dom.isHidden()` allows you to work with logic that determines whether an element is hidden.
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: Cypress.env
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`get` and `set` environment variables *in your tests*.
|
||||
|
||||
{% note info %}
|
||||
The [Environment Variable](https://on.cypress.io/guides/environment-variables) guide explains the 4 ways you can set them *outside of your tests*.
|
||||
The {% url 'Environment Variable' environment-variables %} guide explains the 4 ways you can set them *outside of your tests*.
|
||||
{% endnote %}
|
||||
|
||||
# Syntax
|
||||
@@ -148,10 +148,10 @@ Methods on `cy` are local and specific to a single test. Side effects from `cy`
|
||||
|
||||
**Why would I ever need to use environment variables?**
|
||||
|
||||
The [Environment Variables](https://on.cypress.io/guides/environment-variables) guide explains common use cases.
|
||||
The {% url 'Environment Variables' environment-variables %} guide explains common use cases.
|
||||
|
||||
**Can I pass in environment variables from the command line?**
|
||||
|
||||
Yes. You can do that and much more.
|
||||
|
||||
The [Environment Variables](https://on.cypress.io/guides/environment-variables) guide explains the 4 ways you can set environment variables for your tests.
|
||||
The {% url 'Environment Variables' environment-variables %} guide explains the 4 ways you can set environment variables for your tests.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Server
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Permanently change the default options for all {% url `cy.server()` server %} instances
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.$
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress automatically proxies [jQuery](https://jquery.com/) and exposes it as `Cypress.$`
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user