1- const chai = require ( 'chai' ) ;
2- const expect = chai . expect ;
3- const assert = chai . assert ;
4- const path = require ( 'path' ) ;
1+ const chai = require ( 'chai' )
52
6- const Appium = require ( '../../lib/helper/Appium' ) ;
7- const AssertionFailedError = require ( '../../lib/assert/error' ) ;
8- const fileExists = require ( '../../lib/utils' ) . fileExists ;
9- global . codeceptjs = require ( '../../lib' ) ;
3+ const expect = chai . expect
4+ const assert = chai . assert
5+ const path = require ( 'path' )
106
11- let app ;
7+ const Appium = require ( '../../lib/helper/Appium' )
8+ const AssertionFailedError = require ( '../../lib/assert/error' )
9+ const fileExists = require ( '../../lib/utils' ) . fileExists
10+ global . codeceptjs = require ( '../../lib' )
11+
12+ let app
1213// iOS test app is built from https://github.com/appium/ios-test-app and uploaded to Saucelabs
13- const apk_path = 'storage:filename=TestApp-iphonesimulator.zip' ;
14- const smallWait = 3 ;
14+ const apk_path = 'storage:filename=TestApp-iphonesimulator.zip'
15+ const smallWait = 3
1516
1617describe ( 'Appium iOS Tests' , function ( ) {
17- this . timeout ( 0 ) ;
18+ this . timeout ( 0 )
1819
1920 before ( async ( ) => {
20- global . codecept_dir = path . join ( __dirname , '/../data' ) ;
21+ global . codecept_dir = path . join ( __dirname , '/../data' )
2122 app = new Appium ( {
2223 app : apk_path ,
2324 appiumV2 : true ,
@@ -40,166 +41,166 @@ describe('Appium iOS Tests', function () {
4041 port : 80 ,
4142 user : process . env . SAUCE_USERNAME ,
4243 key : process . env . SAUCE_ACCESS_KEY ,
43- } ) ;
44- await app . _beforeSuite ( ) ;
45- app . isWeb = false ;
46- await app . _before ( ) ;
47- } ) ;
44+ } )
45+ await app . _beforeSuite ( )
46+ app . isWeb = false
47+ await app . _before ( )
48+ } )
4849
4950 after ( async ( ) => {
50- await app . _after ( ) ;
51- } ) ;
51+ await app . _after ( )
52+ } )
5253
5354 describe ( 'app installation : #removeApp' , ( ) => {
5455 describe ( '#grabAllContexts, #grabContext, #grabOrientation, #grabSettings' , ( ) => {
5556 it ( 'should grab all available contexts for screen' , async ( ) => {
56- await app . resetApp ( ) ;
57- const val = await app . grabAllContexts ( ) ;
58- assert . deepEqual ( val , [ 'NATIVE_APP' ] ) ;
59- } ) ;
57+ await app . resetApp ( )
58+ const val = await app . grabAllContexts ( )
59+ assert . deepEqual ( val , [ 'NATIVE_APP' ] )
60+ } )
6061
6162 it ( 'should grab current context' , async ( ) => {
62- const val = await app . grabContext ( ) ;
63- assert . equal ( val , 'NATIVE_APP' ) ;
64- } ) ;
63+ const val = await app . grabContext ( )
64+ assert . equal ( val , 'NATIVE_APP' )
65+ } )
6566
6667 it ( 'should grab custom settings' , async ( ) => {
67- const val = await app . grabSettings ( ) ;
68- assert . deepEqual ( val , { imageElementTapStrategy : 'w3cActions' } ) ;
69- } ) ;
70- } ) ;
71- } ) ;
68+ const val = await app . grabSettings ( )
69+ assert . deepEqual ( val , { imageElementTapStrategy : 'w3cActions' } )
70+ } )
71+ } )
72+ } )
7273
7374 describe ( 'device orientation : #seeOrientationIs #setOrientation' , ( ) => {
7475 it ( 'should return correct status about device orientation' , async ( ) => {
75- await app . seeOrientationIs ( 'PORTRAIT' ) ;
76+ await app . seeOrientationIs ( 'PORTRAIT' )
7677 try {
77- await app . seeOrientationIs ( 'LANDSCAPE' ) ;
78+ await app . seeOrientationIs ( 'LANDSCAPE' )
7879 } catch ( e ) {
79- e . should . be . instanceOf ( AssertionFailedError ) ;
80- e . inspect ( ) . should . include ( 'expected orientation to be LANDSCAPE' ) ;
80+ e . should . be . instanceOf ( AssertionFailedError )
81+ e . inspect ( ) . should . include ( 'expected orientation to be LANDSCAPE' )
8182 }
82- } ) ;
83- } ) ;
83+ } )
84+ } )
8485
8586 describe ( '#hideDeviceKeyboard' , ( ) => {
8687 it ( 'should hide device Keyboard @quick' , async ( ) => {
87- await app . resetApp ( ) ;
88- await app . click ( '~IntegerA' ) ;
88+ await app . resetApp ( )
89+ await app . click ( '~IntegerA' )
8990 try {
90- await app . click ( '~locationStatus' ) ;
91+ await app . click ( '~locationStatus' )
9192 } catch ( e ) {
92- e . message . should . include ( 'element' ) ;
93+ e . message . should . include ( 'element' )
9394 }
94- await app . hideDeviceKeyboard ( 'pressKey' , 'Done' ) ;
95- await app . click ( '~locationStatus' ) ;
96- } ) ;
95+ await app . hideDeviceKeyboard ( 'pressKey' , 'Done' )
96+ await app . click ( '~locationStatus' )
97+ } )
9798
9899 it ( 'should assert if no keyboard' , async ( ) => {
99100 try {
100- await app . hideDeviceKeyboard ( 'pressKey' , 'Done' ) ;
101+ await app . hideDeviceKeyboard ( 'pressKey' , 'Done' )
101102 } catch ( e ) {
102103 e . message . should . include (
103104 'An unknown server-side error occurred while processing the command. Original error: Soft keyboard not present, cannot hide keyboard' ,
104- ) ;
105+ )
105106 }
106- } ) ;
107- } ) ;
107+ } )
108+ } )
108109
109110 describe ( 'see text : #see' , ( ) => {
110111 it ( 'should work inside elements @second' , async ( ) => {
111- await app . resetApp ( ) ;
112- await app . see ( 'Compute Sum' , '~ComputeSumButton' ) ;
113- } ) ;
114- } ) ;
112+ await app . resetApp ( )
113+ await app . see ( 'Compute Sum' , '~ComputeSumButton' )
114+ } )
115+ } )
115116
116117 describe ( '#appendField' , ( ) => {
117118 it ( 'should be able to send special keys to element @second' , async ( ) => {
118- await app . resetApp ( ) ;
119- await app . waitForElement ( '~IntegerA' , smallWait ) ;
120- await app . click ( '~IntegerA' ) ;
121- await app . appendField ( '~IntegerA' , '1' ) ;
122- await app . hideDeviceKeyboard ( 'pressKey' , 'Done' ) ;
123- await app . see ( '1' , '~IntegerA' ) ;
124- } ) ;
125- } ) ;
119+ await app . resetApp ( )
120+ await app . waitForElement ( '~IntegerA' , smallWait )
121+ await app . click ( '~IntegerA' )
122+ await app . appendField ( '~IntegerA' , '1' )
123+ await app . hideDeviceKeyboard ( 'pressKey' , 'Done' )
124+ await app . see ( '1' , '~IntegerA' )
125+ } )
126+ } )
126127
127128 describe ( '#waitForText' , ( ) => {
128129 it ( 'should return error if not present' , async ( ) => {
129130 try {
130- await app . waitForText ( 'Nothing here' , 1 , '~IntegerA' ) ;
131+ await app . waitForText ( 'Nothing here' , 1 , '~IntegerA' )
131132 } catch ( e ) {
132133 e . message . should . contain (
133134 'element (~IntegerA) is not in DOM or there is no element(~IntegerA) with text "Nothing here" after 1 sec' ,
134- ) ;
135+ )
135136 }
136- } ) ;
137- } ) ;
137+ } )
138+ } )
138139
139140 describe ( '#seeNumberOfElements @second' , ( ) => {
140141 it ( 'should return 1 as count' , async ( ) => {
141- await app . resetApp ( ) ;
142- await app . seeNumberOfElements ( '~IntegerA' , 1 ) ;
143- } ) ;
144- } ) ;
142+ await app . resetApp ( )
143+ await app . seeNumberOfElements ( '~IntegerA' , 1 )
144+ } )
145+ } )
145146
146147 describe ( 'see element : #seeElement, #dontSeeElement' , ( ) => {
147148 it ( 'should check visible elements on page @quick' , async ( ) => {
148- await app . resetApp ( ) ;
149- await app . seeElement ( '~IntegerA' ) ;
150- await app . dontSeeElement ( '#something-beyond' ) ;
151- await app . dontSeeElement ( '//input[@id="something-beyond"]' ) ;
152- } ) ;
153- } ) ;
149+ await app . resetApp ( )
150+ await app . seeElement ( '~IntegerA' )
151+ await app . dontSeeElement ( '#something-beyond' )
152+ await app . dontSeeElement ( '//input[@id="something-beyond"]' )
153+ } )
154+ } )
154155
155156 describe ( '#click @quick' , ( ) => {
156157 it ( 'should click by accessibility id' , async ( ) => {
157- await app . resetApp ( ) ;
158- await app . tap ( '~ComputeSumButton' ) ;
159- await app . see ( '0' ) ;
160- } ) ;
161- } ) ;
158+ await app . resetApp ( )
159+ await app . tap ( '~ComputeSumButton' )
160+ await app . see ( '0' )
161+ } )
162+ } )
162163
163164 describe ( '#fillField @second' , ( ) => {
164165 it ( 'should fill field by accessibility id' , async ( ) => {
165- await app . resetApp ( ) ;
166- await app . waitForElement ( '~IntegerA' , smallWait ) ;
167- await app . click ( '~IntegerA' ) ;
168- await app . fillField ( '~IntegerA' , '1' ) ;
169- await app . hideDeviceKeyboard ( 'pressKey' , 'Done' ) ;
170- await app . see ( '1' , '~IntegerA' ) ;
171- } ) ;
172- } ) ;
166+ await app . resetApp ( )
167+ await app . waitForElement ( '~IntegerA' , smallWait )
168+ await app . click ( '~IntegerA' )
169+ await app . fillField ( '~IntegerA' , '1' )
170+ await app . hideDeviceKeyboard ( 'pressKey' , 'Done' )
171+ await app . see ( '1' , '~IntegerA' )
172+ } )
173+ } )
173174
174175 describe ( '#grabTextFrom, #grabValueFrom, #grabAttributeFrom @quick' , ( ) => {
175176 it ( 'should grab text from page' , async ( ) => {
176- await app . resetApp ( ) ;
177- const val = await app . grabTextFrom ( '~ComputeSumButton' ) ;
178- assert . equal ( val , 'Compute Sum' ) ;
179- } ) ;
177+ await app . resetApp ( )
178+ const val = await app . grabTextFrom ( '~ComputeSumButton' )
179+ assert . equal ( val , 'Compute Sum' )
180+ } )
180181
181182 it ( 'should grab attribute from element' , async ( ) => {
182- await app . resetApp ( ) ;
183- const val = await app . grabAttributeFrom ( '~ComputeSumButton' , 'label' ) ;
184- assert . equal ( val , 'Compute Sum' ) ;
185- } ) ;
183+ await app . resetApp ( )
184+ const val = await app . grabAttributeFrom ( '~ComputeSumButton' , 'label' )
185+ assert . equal ( val , 'Compute Sum' )
186+ } )
186187
187188 it ( 'should be able to grab elements' , async ( ) => {
188- await app . resetApp ( ) ;
189- const id = await app . grabNumberOfVisibleElements ( '~ComputeSumButton' ) ;
190- assert . strictEqual ( 1 , id ) ;
191- } ) ;
192- } ) ;
189+ await app . resetApp ( )
190+ const id = await app . grabNumberOfVisibleElements ( '~ComputeSumButton' )
191+ assert . strictEqual ( 1 , id )
192+ } )
193+ } )
193194
194195 describe ( '#saveScreenshot' , ( ) => {
195196 beforeEach ( ( ) => {
196- global . output_dir = path . join ( global . codecept_dir , 'output' ) ;
197- } ) ;
197+ global . output_dir = path . join ( global . codecept_dir , 'output' )
198+ } )
198199
199200 it ( 'should create a screenshot file in output dir' , async ( ) => {
200- const sec = new Date ( ) . getUTCMilliseconds ( ) ;
201- await app . saveScreenshot ( `screenshot_${ sec } .png` ) ;
202- assert . ok ( fileExists ( path . join ( global . output_dir , `screenshot_${ sec } .png` ) ) , null , 'file does not exists' ) ;
203- } ) ;
204- } ) ;
205- } ) ;
201+ const sec = new Date ( ) . getUTCMilliseconds ( )
202+ await app . saveScreenshot ( `screenshot_${ sec } .png` )
203+ assert . ok ( fileExists ( path . join ( global . output_dir , `screenshot_${ sec } .png` ) ) , null , 'file does not exists' )
204+ } )
205+ } )
206+ } )
0 commit comments