@@ -127,13 +127,25 @@ describe("DateTimePicker", () => {
127
127
} ) ;
128
128
129
129
it ( "Should select date from de_De locale picker and verify format" , async ( ) => {
130
- await scrollToElement ( driver , "preferred locale: de_DE" , Direction . down ) ;
130
+ await scrollToElement ( driver , "zeit wählen" , Direction . down ) ;
131
+ const deLocale = await driver . findElementByText ( "preferred locale: de_DE" ) ;
132
+ expect ( deLocale ) . to . exist ;
131
133
const datePicker = await driver . findElementByText ( "datum auswählen" , SearchOptions . contains ) ;
132
134
await datePicker . click ( ) ;
133
135
const date = await getPickerDate ( driver ) ;
134
- const acceptBtn = await driver . findElementByText ( "BestÄtigen" , SearchOptions . contains ) ;
135
- const rejectBtn = await driver . findElementByText ( "Stornieren" , SearchOptions . contains ) ;
136
- const title = await driver . findElementByText ( "Datum auswählen" , SearchOptions . contains ) ;
136
+ let selector = isAndroid ? "android.widget.Button" : "Bestätigen" ;
137
+ let acceptBtn ;
138
+ let rejectBtn ;
139
+ if ( isAndroid ) {
140
+ let buttons = await driver . findElementsByClassName ( selector ) ;
141
+ acceptBtn = buttons [ 7 ] ;
142
+ rejectBtn = buttons [ 6 ] ;
143
+ }
144
+ else {
145
+ acceptBtn = await driver . findElementByText ( selector , SearchOptions . contains ) ;
146
+ rejectBtn = await driver . findElementByText ( "Stornieren" , SearchOptions . exact ) ;
147
+ }
148
+ const title = await driver . findElementByText ( "Datum auswählen" , SearchOptions . exact ) ;
137
149
expect ( acceptBtn ) . to . exist ;
138
150
expect ( rejectBtn ) . to . exist ;
139
151
expect ( title ) . to . exist ;
@@ -147,4 +159,108 @@ describe("DateTimePicker", () => {
147
159
expect ( dateString ) . to . exist ;
148
160
} ) ;
149
161
162
+ it ( "Should select time from de_DE locale picker and verify format" , async ( ) => {
163
+ const timePicker = await driver . findElementByText ( "zeit wählen" , SearchOptions . contains ) ;
164
+ await timePicker . click ( ) ;
165
+ const time = await getPickerTime ( driver , 12 ) ;
166
+ let acceptBtn ;
167
+ let rejectBtn ;
168
+ if ( isAndroid ) {
169
+ let buttons = await driver . findElementsByClassName ( "android.widget.Button" ) ;
170
+ acceptBtn = buttons [ 6 ] ;
171
+ rejectBtn = buttons [ 5 ] ;
172
+ }
173
+ else {
174
+ acceptBtn = await driver . findElementByText ( "Bestätigen" , SearchOptions . exact ) ;
175
+ rejectBtn = await driver . findElementByText ( "Stornieren" , SearchOptions . exact ) ;
176
+ }
177
+ const title = await driver . findElementByText ( "Zeit wählen" , SearchOptions . exact ) ;
178
+ expect ( acceptBtn ) . to . exist ;
179
+ expect ( rejectBtn ) . to . exist ;
180
+ expect ( title ) . to . exist ;
181
+ await acceptBtn . click ( ) ;
182
+ let timeString = time . substr ( 0 , time . indexOf ( " " ) ) ;
183
+ timeString = timeString + " nachm." ;
184
+ console . log ( timeString ) ;
185
+ const dateField = await driver . findElementByText ( timeString ) ;
186
+ expect ( timeString ) . to . exist ;
187
+ } ) ;
188
+
189
+ it ( "Should scroll to custom format and verify values" , async ( ) => {
190
+ await scrollToElement ( driver , "binding" , Direction . down ) ;
191
+ const customFromatLabel = await driver . findElementByText ( "custom format" ) ;
192
+ expect ( customFromatLabel ) . to . exist ;
193
+ const customFormatDate = await driver . findElementByText ( "date: 24 February 2019" , SearchOptions . exact ) ;
194
+ expect ( customFormatDate ) . to . exist ;
195
+ const customFormatTime = await driver . findElementByText ( "time: 01:00" , SearchOptions . exact ) ;
196
+ expect ( customFormatTime ) . to . exist ;
197
+ } ) ;
198
+
199
+ it ( "Should scroll to binding example and verify picker and label values" , async ( ) => {
200
+ await scrollToElement ( driver , "css applied" , Direction . down ) ;
201
+ const bindingLabel = await driver . findElementByText ( "binding" , SearchOptions . exact ) ;
202
+ expect ( bindingLabel ) . to . exist ;
203
+ let selector = isAndroid ? "android.widget.EditText" : "XCUIElementTypeTextField"
204
+ let fields = await driver . findElementsByClassName ( selector ) ;
205
+ let timeField ;
206
+ let dateField ;
207
+ if ( isAndroid ) {
208
+ timeField = fields [ 2 ] ;
209
+ dateField = fields [ 1 ] ;
210
+ }
211
+ else {
212
+ let index = fields . length - 3 ;
213
+ console . log ( "index: " + index ) ;
214
+ timeField = fields [ index ] ;
215
+ dateField = fields [ index - 1 ] ;
216
+ }
217
+ await dateField . click ( ) ;
218
+ let date = await getPickerDate ( driver ) ;
219
+ await clickOkBtn ( driver ) ;
220
+ let dateTime = new Date ( date ) ;
221
+ let year = dateTime . getFullYear ( ) . toString ( ) ;
222
+ let dateLabel = dateTime . toString ( ) . substring ( 0 , dateTime . toString ( ) . indexOf ( year ) + 4 ) ;
223
+ console . log ( dateLabel ) ;
224
+ let bindingDate = await driver . findElementByText ( dateLabel , SearchOptions . contains ) ;
225
+ } ) ;
226
+
227
+ it ( "Should scroll to css styled DatePicker and verify picker style" , async ( ) => {
228
+ await scrollToElement ( driver , "tap to select time" , Direction . down ) ;
229
+ const cssPicker = await driver . findElementByText ( "Feb 24, 2019" , SearchOptions . exact ) ;
230
+ await cssPicker . click ( ) ;
231
+ await getPickerDate ( driver ) ;
232
+ await driver . compareScreen ( "cssDatePicker" ) ;
233
+ await clickOkBtn ( driver ) ;
234
+ } ) ;
235
+
236
+ it ( "Should scroll to css styled TimePicker and verify picker style" , async ( ) => {
237
+ const cssPicker = await driver . findElementByText ( "1:00 AM" , SearchOptions . exact ) ;
238
+ await cssPicker . click ( ) ;
239
+ await getPickerTime ( driver , 12 ) ;
240
+ await driver . compareScreen ( "cssTimePicker" ) ;
241
+ await clickOkBtn ( driver ) ;
242
+ } ) ;
243
+
244
+ it ( "Should tap button to select date and verify button text" , async ( ) => {
245
+ let dateButton = await driver . findElementByText ( "tap to select date" , SearchOptions . contains ) ;
246
+ await dateButton . click ( ) ;
247
+ const date = await getPickerDate ( driver ) ;
248
+ await clickOkBtn ( driver ) ;
249
+ const dateString = new Date ( date ) . toLocaleDateString ( 'de-DE' , {
250
+ year : 'numeric' ,
251
+ month : '2-digit' ,
252
+ day : 'numeric'
253
+ } ) ;
254
+ const dateField = await driver . findElementByText ( dateString ) ;
255
+ expect ( dateString ) . to . exist ;
256
+ } )
257
+
258
+ it ( "Should tap button to select time and verify button text" , async ( ) => {
259
+ let timeButton = await driver . findElementByText ( "tap to select time" , SearchOptions . contains ) ;
260
+ await timeButton . click ( ) ;
261
+ const time = await getPickerTime ( driver , 24 ) ;
262
+ await clickOkBtn ( driver ) ;
263
+ timeButton = await driver . findElementByText ( time ) ;
264
+ expect ( timeButton ) . to . exist ;
265
+ } ) ;
150
266
} ) ;
0 commit comments