@@ -9,50 +9,51 @@ context('Actions', () => {
99
1010 it ( '.type() - type into a DOM element' , ( ) => {
1111 // https://on.cypress.io/type
12- cy . get ( '.action-email' )
13- . type ( '[email protected] ') . should ( 'have.value' , '[email protected] ' ) 12+ cy . get ( '.action-email' ) . type ( '[email protected] ' ) 13+ cy . get ( '.action-email ') . should ( 'have.value' , '[email protected] ' ) 1414
15- // .type() with special character sequences
16- . type ( '{leftarrow}{rightarrow}{uparrow}{downarrow}' )
17- . type ( '{del}{selectall}{backspace}' )
15+ // .type() with special character sequences
16+ cy . get ( '.action-email' ) . type ( '{leftarrow}{rightarrow}{uparrow}{downarrow}' )
17+ cy . get ( '.action-email' ) . type ( '{del}{selectall}{backspace}' )
1818
19- // .type() with key modifiers
20- . type ( '{alt}{option}' ) //these are equivalent
21- . type ( '{ctrl}{control}' ) //these are equivalent
22- . type ( '{meta}{command}{cmd}' ) //these are equivalent
23- . type ( '{shift}' )
19+ // .type() with key modifiers
20+ cy . get ( '.action-email' ) . type ( '{alt}{option}' ) //these are equivalent
21+ cy . get ( '.action-email' ) . type ( '{ctrl}{control}' ) //these are equivalent
22+ cy . get ( '.action-email' ) . type ( '{meta}{command}{cmd}' ) //these are equivalent
23+ cy . get ( '.action-email' ) . type ( '{shift}' )
2424
25- // Delay each keypress by 0.1 sec
26- . type ( '[email protected] ' , { delay :
100 } ) 27- . should ( 'have.value' , '[email protected] ' ) 25+ // Delay each keypress by 0.1 sec
26+ cy . get ( '.action-email' ) . type ( '[email protected] ' , { delay :
100 } ) 27+ cy . get ( '.action-email' ) . should ( 'have.value' , '[email protected] ' ) 2828
2929 cy . get ( '.action-disabled' )
3030 // Ignore error checking prior to type
3131 // like whether the input is visible or disabled
3232 . type ( 'disabled error checking' , { force : true } )
33- . should ( 'have.value' , 'disabled error checking' )
33+ cy . get ( '.action-disabled' ) . should ( 'have.value' , 'disabled error checking' )
3434 } )
3535
3636 it ( '.focus() - focus on a DOM element' , ( ) => {
3737 // https://on.cypress.io/focus
3838 cy . get ( '.action-focus' ) . focus ( )
39- . should ( 'have.class' , 'focus' )
39+ cy . get ( '.action-focus' ) . should ( 'have.class' , 'focus' )
4040 . prev ( ) . should ( 'have.attr' , 'style' , 'color: orange;' )
4141 } )
4242
4343 it ( '.blur() - blur off a DOM element' , ( ) => {
4444 // https://on.cypress.io/blur
45- cy . get ( '.action-blur' ) . type ( 'About to blur' ) . blur ( )
46- . should ( 'have.class' , 'error' )
45+ cy . get ( '.action-blur' ) . type ( 'About to blur' )
46+ cy . get ( '.action-blur' ) . blur ( )
47+ cy . get ( '.action-blur' ) . should ( 'have.class' , 'error' )
4748 . prev ( ) . should ( 'have.attr' , 'style' , 'color: red;' )
4849 } )
4950
5051 it ( '.clear() - clears an input or textarea element' , ( ) => {
5152 // https://on.cypress.io/clear
5253 cy . get ( '.action-clear' ) . type ( 'Clear this text' )
53- . should ( 'have.value' , 'Clear this text' )
54- . clear ( )
55- . should ( 'have.value' , '' )
54+ cy . get ( '.action-clear' ) . should ( 'have.value' , 'Clear this text' )
55+ cy . get ( '.action-clear' ) . clear ( )
56+ cy . get ( '.action-clear' ) . should ( 'have.value' , '' )
5657 } )
5758
5859 it ( '.submit() - submit a form' , ( ) => {
@@ -61,7 +62,7 @@ context('Actions', () => {
6162 . find ( '[type="text"]' ) . type ( 'HALFOFF' )
6263
6364 cy . get ( '.action-form' ) . submit ( )
64- . next ( ) . should ( 'contain' , 'Your form has been submitted!' )
65+ cy . get ( '.action-form' ) . next ( ) . should ( 'contain' , 'Your form has been submitted!' )
6566 } )
6667
6768 it ( '.click() - click on a DOM element' , ( ) => {
@@ -97,13 +98,13 @@ context('Actions', () => {
9798 // that controls where the click occurs :)
9899
99100 cy . get ( '#action-canvas' )
100- . click ( 80 , 75 ) // click 80px on x coord and 75px on y coord
101- . click ( 170 , 75 )
102- . click ( 80 , 165 )
103- . click ( 100 , 185 )
104- . click ( 125 , 190 )
105- . click ( 150 , 185 )
106- . click ( 170 , 165 )
101+ cy . get ( '#action-canvas' ) . click ( 80 , 75 ) // click 80px on x coord and 75px on y coord
102+ cy . get ( '#action-canvas' ) . click ( 170 , 75 )
103+ cy . get ( '#action-canvas' ) . click ( 80 , 165 )
104+ cy . get ( '#action-canvas' ) . click ( 100 , 185 )
105+ cy . get ( '#action-canvas' ) . click ( 125 , 190 )
106+ cy . get ( '#action-canvas' ) . click ( 150 , 185 )
107+ cy . get ( '#action-canvas' ) . click ( 170 , 165 )
107108
108109 // click multiple elements by passing multiple: true
109110 cy . get ( '.action-labels>.label' ) . click ( { multiple : true } )
@@ -117,7 +118,8 @@ context('Actions', () => {
117118
118119 // Our app has a listener on 'dblclick' event in our 'scripts.js'
119120 // that hides the div and shows an input on double click
120- cy . get ( '.action-div' ) . dblclick ( ) . should ( 'not.be.visible' )
121+ cy . get ( '.action-div' ) . dblclick ( )
122+ cy . get ( '.action-div' ) . should ( 'not.be.visible' )
121123 cy . get ( '.action-input-hidden' ) . should ( 'be.visible' )
122124 } )
123125
@@ -126,7 +128,8 @@ context('Actions', () => {
126128
127129 // Our app has a listener on 'contextmenu' event in our 'scripts.js'
128130 // that hides the div and shows an input on right click
129- cy . get ( '.rightclick-action-div' ) . rightclick ( ) . should ( 'not.be.visible' )
131+ cy . get ( '.rightclick-action-div' ) . rightclick ( )
132+ cy . get ( '.rightclick-action-div' ) . should ( 'not.be.visible' )
130133 cy . get ( '.rightclick-action-input-hidden' ) . should ( 'be.visible' )
131134 } )
132135
@@ -135,26 +138,26 @@ context('Actions', () => {
135138
136139 // By default, .check() will check all
137140 // matching checkbox or radio elements in succession, one after another
138- cy . get ( '.action-checkboxes [type="checkbox"]' ) . not ( '[disabled]' )
139- . check ( ) . should ( 'be.checked' )
141+ cy . get ( '.action-checkboxes [type="checkbox"]' ) . not ( '[disabled]' ) . check ( )
142+ cy . get ( '.action-checkboxes [type="checkbox"]' ) . not ( '[disabled]' ) . should ( 'be.checked' )
140143
141- cy . get ( '.action-radios [type="radio"]' ) . not ( '[disabled]' )
142- . check ( ) . should ( 'be.checked' )
144+ cy . get ( '.action-radios [type="radio"]' ) . not ( '[disabled]' ) . check ( )
145+ cy . get ( '.action-radios [type="radio"]' ) . not ( '[disabled]' ) . should ( 'be.checked' )
143146
144147 // .check() accepts a value argument
145- cy . get ( '.action-radios [type="radio"]' )
146- . check ( 'radio1 ') . should ( 'be.checked' )
148+ cy . get ( '.action-radios [type="radio"]' ) . check ( 'radio1' )
149+ cy . get ( '.action-radios [type="radio"] ') . should ( 'be.checked' )
147150
148151 // .check() accepts an array of values
149- cy . get ( '.action-multiple-checkboxes [type="checkbox"]' )
150- . check ( [ 'checkbox1' , 'checkbox2' ] ) . should ( 'be.checked' )
152+ cy . get ( '.action-multiple-checkboxes [type="checkbox"]' ) . check ( [ 'checkbox1' , 'checkbox2' ] )
153+ cy . get ( '.action-multiple-checkboxes [type="checkbox"]' ) . should ( 'be.checked' )
151154
152155 // Ignore error checking prior to checking
153- cy . get ( '.action-checkboxes [disabled]' )
154- . check ( { force : true } ) . should ( 'be.checked' )
156+ cy . get ( '.action-checkboxes [disabled]' ) . check ( { force : true } )
157+ cy . get ( '.action-checkboxes [disabled]' ) . should ( 'be.checked' )
155158
156- cy . get ( '.action-radios [type="radio"]' )
157- . check ( 'radio3' , { force : true } ) . should ( 'be.checked' )
159+ cy . get ( '.action-radios [type="radio"]' ) . check ( 'radio3' , { force : true } )
160+ cy . get ( '.action-radios [type="radio"]' ) . should ( 'be.checked' )
158161 } )
159162
160163 it ( '.uncheck() - uncheck a checkbox element' , ( ) => {
@@ -164,21 +167,32 @@ context('Actions', () => {
164167 // checkbox elements in succession, one after another
165168 cy . get ( '.action-check [type="checkbox"]' )
166169 . not ( '[disabled]' )
167- . uncheck ( ) . should ( 'not.be.checked' )
170+ . uncheck ( )
171+ cy . get ( '.action-check [type="checkbox"]' )
172+ . not ( '[disabled]' )
173+ . should ( 'not.be.checked' )
168174
169175 // .uncheck() accepts a value argument
170176 cy . get ( '.action-check [type="checkbox"]' )
171177 . check ( 'checkbox1' )
172- . uncheck ( 'checkbox1' ) . should ( 'not.be.checked' )
178+ cy . get ( '.action-check [type="checkbox"]' )
179+ . uncheck ( 'checkbox1' )
180+ cy . get ( '.action-check [type="checkbox"][value="checkbox1"]' )
181+ . should ( 'not.be.checked' )
173182
174183 // .uncheck() accepts an array of values
175184 cy . get ( '.action-check [type="checkbox"]' )
176185 . check ( [ 'checkbox1' , 'checkbox3' ] )
177- . uncheck ( [ 'checkbox1' , 'checkbox3' ] ) . should ( 'not.be.checked' )
186+ cy . get ( '.action-check [type="checkbox"]' )
187+ . uncheck ( [ 'checkbox1' , 'checkbox3' ] )
188+ cy . get ( '.action-check [type="checkbox"][value="checkbox1"]' )
189+ . should ( 'not.be.checked' )
190+ cy . get ( '.action-check [type="checkbox"][value="checkbox3"]' )
191+ . should ( 'not.be.checked' )
178192
179193 // Ignore error checking prior to unchecking
180- cy . get ( '.action-check [disabled]' )
181- . uncheck ( { force : true } ) . should ( 'not.be.checked' )
194+ cy . get ( '.action-check [disabled]' ) . uncheck ( { force : true } )
195+ cy . get ( '.action-check [disabled]' ) . should ( 'not.be.checked' )
182196 } )
183197
184198 it ( '.select() - select an option in a <select> element' , ( ) => {
@@ -196,17 +210,20 @@ context('Actions', () => {
196210
197211 cy . get ( '.action-select-multiple' )
198212 . select ( [ 'apples' , 'oranges' , 'bananas' ] )
213+ cy . get ( '.action-select-multiple' )
199214 // when getting multiple values, invoke "val" method first
200215 . invoke ( 'val' )
201216 . should ( 'deep.equal' , [ 'fr-apples' , 'fr-oranges' , 'fr-bananas' ] )
202217
203218 // Select option(s) with matching value
204219 cy . get ( '.action-select' ) . select ( 'fr-bananas' )
220+ cy . get ( '.action-select' )
205221 // can attach an assertion right away to the element
206222 . should ( 'have.value' , 'fr-bananas' )
207223
208224 cy . get ( '.action-select-multiple' )
209225 . select ( [ 'fr-apples' , 'fr-oranges' , 'fr-bananas' ] )
226+ cy . get ( '.action-select-multiple' )
210227 . invoke ( 'val' )
211228 . should ( 'deep.equal' , [ 'fr-apples' , 'fr-oranges' , 'fr-bananas' ] )
212229
@@ -227,20 +244,23 @@ context('Actions', () => {
227244
228245 // scroll the button into view, as if the user had scrolled
229246 cy . get ( '#scroll-horizontal button' ) . scrollIntoView ( )
247+ cy . get ( '#scroll-horizontal button' )
230248 . should ( 'be.visible' )
231249
232250 cy . get ( '#scroll-vertical button' )
233251 . should ( 'not.be.visible' )
234252
235253 // Cypress handles the scroll direction needed
236254 cy . get ( '#scroll-vertical button' ) . scrollIntoView ( )
255+ cy . get ( '#scroll-vertical button' )
237256 . should ( 'be.visible' )
238257
239258 cy . get ( '#scroll-both button' )
240259 . should ( 'not.be.visible' )
241260
242261 // Cypress knows to scroll to the right and down
243262 cy . get ( '#scroll-both button' ) . scrollIntoView ( )
263+ cy . get ( '#scroll-both button' )
244264 . should ( 'be.visible' )
245265 } )
246266
@@ -255,7 +275,9 @@ context('Actions', () => {
255275 // the value and trigger the 'change' event
256276 cy . get ( '.trigger-input-range' )
257277 . invoke ( 'val' , 25 )
278+ cy . get ( '.trigger-input-range' )
258279 . trigger ( 'change' )
280+ cy . get ( '.trigger-input-range' )
259281 . get ( 'input[type=range]' ) . siblings ( 'p' )
260282 . should ( 'have.text' , '25' )
261283 } )
0 commit comments