1
- import { AppiumDriver , createDriver , SearchOptions } from "nativescript-dev-appium" ;
1
+ import { AppiumDriver , createDriver , SearchOptions , Direction } from "nativescript-dev-appium" ;
2
2
import { isSauceLab , runType } from "nativescript-dev-appium/lib/parser" ;
3
3
import { expect } from "chai" ;
4
4
import { ok } from "assert" ;
5
- import { getDateString , getPickerTime } from "./helper" ;
5
+ import { getPickerTime , clickOkBtn , scrollToElement , getPickerDate } from "./helper" ;
6
6
const fs = require ( 'fs' ) ;
7
7
const addContext = require ( 'mochawesome/addContext' ) ;
8
8
const rimraf = require ( 'rimraf' ) ;
@@ -54,28 +54,97 @@ describe("DateTimePicker", () => {
54
54
it ( "Should select date and verify value of picker field" , async ( ) => {
55
55
const selectDateField = await driver . findElementByText ( "select date" , SearchOptions . contains ) ;
56
56
await selectDateField . click ( ) ;
57
- const okBtn = await driver . findElementByText ( "OK" , SearchOptions . exact ) ;
58
- await okBtn . click ( ) ;
59
- const date = getDateString ( ) ;
60
- console . log ( date ) ;
57
+ const date = await getPickerDate ( driver ) ;
58
+ await clickOkBtn ( driver ) ;
61
59
const dateSelected = await driver . findElementByText ( date ) ;
62
60
expect ( dateSelected ) . to . exist ;
63
61
} ) ;
64
62
65
63
it ( "Should select time and verify value of picker field" , async ( ) => {
66
64
const selectTimeField = await driver . findElementByText ( "select time" , SearchOptions . contains ) ;
67
65
await selectTimeField . click ( ) ;
68
- const timeString = await getPickerTime ( ) ;
69
-
70
- const okBtn = await driver . findElementByText ( "OK" , SearchOptions . exact ) ;
71
- await okBtn . click ( ) ;
66
+ const timeString = await getPickerTime ( driver , 12 ) ;
67
+ await clickOkBtn ( driver ) ;
72
68
const timeSelected = await driver . findElementByText ( timeString , SearchOptions . contains ) ;
73
69
expect ( timeSelected ) . to . exist ;
74
70
} ) ;
75
71
76
72
it ( "Should select date from min/max limited field" , async ( ) => {
77
- const minMaxLabel = await driver . findElementByText ( "min and max date" , SearchOptions . contains ) ;
78
-
73
+ const minMaxDatePicker = await driver . findElementByText ( "tap to select" , SearchOptions . contains ) ;
74
+ await minMaxDatePicker . click ( ) ;
75
+ const date = await getPickerDate ( driver ) ;
76
+ await clickOkBtn ( driver ) ;
77
+ const dateSelected = await driver . findElementByText ( date ) ;
78
+ expect ( dateSelected ) . to . exist ;
79
+ } ) ;
80
+
81
+ it ( "Should open 12h time format and verify wheelers values" , async ( ) => {
82
+ const twelveHourFormat = await driver . findElementByText ( "4:00 PM" , SearchOptions . contains ) ;
83
+ await twelveHourFormat . click ( ) ;
84
+ const timeString = await getPickerTime ( driver , 12 ) ;
85
+ await clickOkBtn ( driver ) ;
86
+ expect ( timeString ) . to . equal ( "4:00 PM" ) ;
87
+ } ) ;
88
+
89
+ it ( "Should open 24h format and verify wheeler value" , async ( ) => {
90
+ const twentyFourFormat = await scrollToElement ( driver , "16:00" , Direction . down ) ;
91
+ await twentyFourFormat . click ( ) ;
92
+ const timeString = await getPickerTime ( driver , 24 ) ;
93
+ await clickOkBtn ( driver ) ;
94
+ expect ( timeString ) . to . equal ( "16:00" ) ;
95
+ } ) ;
96
+
97
+ it ( "Should verify modified texts field for date picker" , async ( ) => {
98
+ await scrollToElement ( driver , "modified picker texts" , Direction . down ) ;
99
+ const pickers = await driver . findElementsByText ( "tap to choose" ) ;
100
+ const datePicker = pickers [ 0 ] ;
101
+ await datePicker . click ( ) ;
102
+ const date = await getPickerDate ( driver ) ;
103
+ const approveBtn = await driver . findElementByText ( "Approve" , SearchOptions . contains ) ;
104
+ const rejectBtn = await driver . findElementByText ( "Reject" , SearchOptions . contains ) ;
105
+ const title = await driver . findElementByText ( "Confirm predefined date selection" , SearchOptions . contains ) ;
106
+ expect ( approveBtn ) . to . exist ;
107
+ expect ( rejectBtn ) . to . exist ;
108
+ expect ( title ) . to . exist ;
109
+ await approveBtn . click ( ) ;
110
+ const dateString = await driver . findElementByText ( date ) ;
111
+ expect ( dateString ) . to . exist ;
112
+ } ) ;
113
+
114
+ it ( "Should verify modified texts field for time picker" , async ( ) => {
115
+ const datePicker = await driver . findElementByText ( "tap to choose" ) ;
116
+ await datePicker . click ( ) ;
117
+ const time = await getPickerTime ( driver , 12 ) ;
118
+ const approveBtn = await driver . findElementByText ( "Approve" , SearchOptions . contains ) ;
119
+ const rejectBtn = await driver . findElementByText ( "Reject" , SearchOptions . contains ) ;
120
+ const title = await driver . findElementByText ( "Confirm predefined time selection" , SearchOptions . contains ) ;
121
+ expect ( approveBtn ) . to . exist ;
122
+ expect ( rejectBtn ) . to . exist ;
123
+ expect ( title ) . to . exist ;
124
+ await approveBtn . click ( ) ;
125
+ const dateString = await driver . findElementByText ( time ) ;
126
+ expect ( dateString ) . to . exist ;
127
+ } ) ;
128
+
129
+ it ( "Should select date from de_De locale picker and verify format" , async ( ) => {
130
+ await scrollToElement ( driver , "preferred locale: de_DE" , Direction . down ) ;
131
+ const datePicker = await driver . findElementByText ( "datum auswählen" , SearchOptions . contains ) ;
132
+ await datePicker . click ( ) ;
133
+ 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 ) ;
137
+ expect ( acceptBtn ) . to . exist ;
138
+ expect ( rejectBtn ) . to . exist ;
139
+ expect ( title ) . to . exist ;
140
+ await acceptBtn . click ( ) ;
141
+ const dateString = new Date ( date ) . toLocaleDateString ( 'de-DE' , {
142
+ year : 'numeric' ,
143
+ month : '2-digit' ,
144
+ day : 'numeric'
145
+ } ) ;
146
+ const dateField = await driver . findElementByText ( dateString ) ;
147
+ expect ( dateString ) . to . exist ;
79
148
} ) ;
80
149
81
150
} ) ;
0 commit comments