-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
misc.html
199 lines (181 loc) · 7.72 KB
/
misc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Kitchen Sink | Cypress Example">
<meta name="author" content="Cypress.io">
<meta name="copyright" content="Cypress.io, Inc">
<title>Cypress.io: Kitchen Sink</title>
<link rel="icon" href="/assets/img/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="/assets/css/vendor/bootstrap.min.css">
<link rel="stylesheet" href="/assets/css/vendor/fira.css">
<link rel="stylesheet" href="/assets/css/styles.css">
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">cypress.io</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Commands <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/commands/querying">Querying</a></li>
<li><a href="/commands/traversal">Traversal</a></li>
<li><a href="/commands/actions">Actions</a></li>
<li><a href="/commands/window">Window</a></li>
<li><a href="/commands/viewport">Viewport</a></li>
<li><a href="/commands/location">Location</a></li>
<li><a href="/commands/navigation">Navigation</a></li>
<li><a href="/commands/assertions">Assertions</a></li>
<li class="active"><a href="/commands/misc">Misc</a></li>
<li><a href="/commands/connectors">Connectors</a></li>
<li><a href="/commands/aliasing">Aliasing</a></li>
<li><a href="/commands/waiting">Waiting</a></li>
<li><a href="/commands/network-requests">Network Requests</a></li>
<li><a href="/commands/files">Files</a></li>
<li><a href="/commands/storage">Storage</a></li>
<li><a href="/commands/cookies">Cookies</a></li>
<li><a href="/commands/spies-stubs-clocks">Spies, Stubs & Clocks</a></li>
</ul>
</li>
<li><a href="/utilities">Utilities</a></li>
<li><a href="/cypress-api">Cypress API</a></li>
</ul>
<ul class="nav navbar-nav pull-right">
<li><a href="https://github.com/cypress-io/cypress-example-kitchensink">GitHub</a></li>
</ul>
</div>
</div>
</nav>
<div class="banner">
<div class="container">
<h1>Misc</h1>
<p>Examples of miscellaneous commands in Cypress, for a full reference of commands, go to <a href="https://on.cypress.io/api" target="_blank">docs.cypress.io</a>
</p>
</div>
</div>
<div class="container content-container">
<div id="misc">
<div class="row">
<div class="col-xs-7">
<h4 id="end"><a href="https://on.cypress.io/end">.end()</a></h4>
<p>To end the command chain, use the <a href="https://on.cypress.io/end"><code>.end()</code></a> command.</p>
<pre><code class="javascript">// cy.end is useful when you want to end a chain of commands
// and force Cypress to re-query from the root element
cy.get('.misc-table').within(() => {
// ends the current chain and yields null
cy.contains('Cheryl').click().end()
// queries the entire table again
cy.contains('Charles').click()
})</code></pre>
</div>
<div class="col-xs-5">
<div class="well">
<table class="table table-bordered misc-table">
<thead>
<tr>
<th>Table</th>
</tr>
</thead>
<tbody>
<tr>
<td>User: Cheryl</td>
</tr>
<tr>
<td>User: Charles</td>
</tr>
<tr>
<td>User: Darryl</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-xs-12"><hr></div>
<div class="col-xs-12">
<h4 id="exec"><a href="https://on.cypress.io/exec">cy.exec()</a></h4>
<p>To execute a system command, use the <a href="https://on.cypress.io/exec"><code>cy.exec()</code></a> command.</p>
<pre><code class="javascript">// execute a system command.
// so you can take actions necessary for
// your test outside the scope of Cypress.
cy.exec('echo Jane Lane')
.its('stdout').should('contain', 'Jane Lane')
// we can use Cypress.platform string to
// select appropriate command
cy.log(`Platform ${Cypress.platform} architecture ${Cypress.arch}`)
if (Cypress.platform === 'win32') {
cy.exec('print cypress.config.js')
.its('stderr').should('be.empty')
} else {
cy.exec('cat cypress.config.js')
.its('stderr').should('be.empty')
cy.exec('pwd')
.its('code').should('eq', 0)
}</code></pre>
</div>
<div class="col-xs-12"><hr></div>
<div class="col-xs-7">
<h4 id="focused"><a href="https://on.cypress.io/focused">cy.focused()</a></h4>
<p>To get the DOM element that has focus, use the <a href="https://on.cypress.io/focused"><code>cy.focused()</code></a> command.</p>
<pre><code class="javascript">cy.get('.misc-form').find('#name').click()
cy.focused().should('have.id', 'name')
cy.get('.misc-form').find('#description').click()
cy.focused().should('have.id', 'description')</code></pre>
</div>
<div class="col-xs-5">
<div class="well">
<form class="misc-form">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name">
</div>
<div class="form-group">
<label for="description">Description</label>
<textarea class="form-control" id="description"></textarea>
</div>
</form>
</div>
</div>
<div class="col-xs-12"><hr></div>
<div class="col-xs-7">
<h4 id="screenshot"><a href="https://on.cypress.io/screenshot">cy.screenshot()</a></h4>
<p>To take a screenshot, use the <a href="https://on.cypress.io/screenshot"><code>cy.screenshot()</code></a> command.</p>
<pre><code class="javascript">cy.screenshot('my-image')</code></pre>
</div>
<div class="col-xs-5">
<div class="well">
<code>cypress/screenshots/my-image.png</code>
</div>
</div>
<div class="col-xs-12"><hr></div>
<div class="col-xs-7">
<h4 id="wrap"><a href="https://on.cypress.io/wrap">cy.wrap()</a></h4>
<p>To wrap an object, use the <a href="https://on.cypress.io/wrap"><code>cy.wrap()</code></a> command.</p>
<pre><code class="javascript">cy.wrap({foo: 'bar'})
.should('have.property', 'foo')
.and('include', 'bar')</code></pre>
</div>
<div class="col-xs-5">
<div class="well">
<code>{foo: bar}</code>
</div>
</div>
<div class="col-xs-12"><hr></div>
</div>
</div>
</div>
<script src="/assets/js/vendor/jquery-1.12.0.min.js"></script>
<script src="/assets/js/vendor/bootstrap.min.js"></script>
<script src="/assets/js/vendor/highlight.pack.js"></script>
<script src="/assets/js/scripts.js"></script>
</body>
</html>