1
- import { $ , $$ , browser , by , element , ElementFinder , ExpectedConditions } from 'protractor' ;
2
-
1
+ import { $ , $$ , browser , by , element , ElementFinder , ExpectedConditions , protractor } from 'protractor' ;
3
2
4
3
export class DemoPage {
5
4
private popupSelector = '.dp-popup.dp-main' ;
6
5
emptyElem = $ ( '.dp-place-holder' ) ;
7
- dayPickerInput = $ ( '#datePicker input' ) ;
8
- timePickerInput = $ ( '#timePicker input' ) ;
9
- daytimePickerInput = $ ( '#daytimePicker input' ) ;
10
- daytimeDirectiveInput = $ ( '#daytimeDirective input' ) ;
11
- dayDirectiveInput = $ ( '#dayDirective input' ) ;
12
- dayDirectiveReactiveInput = $ ( '#datePickerDirDayReactive input' ) ;
13
- monthDirectiveInput = $ ( '#datePickerDirMonth input' ) ;
14
- timeSelectDirectiveInput = $ ( '#timePickerDirDay input' ) ;
6
+ dayPickerInput = $ ( '#picker input' ) ;
7
+ timePickerInput = $ ( '#picker input' ) ;
8
+ daytimePickerInput = $ ( '#picker input' ) ;
9
+ daytimeDirectiveInput = $ ( 'input#picker' ) ;
10
+ dayDirectiveInput = $ ( 'input#picker' ) ;
11
+ monthDirectiveInput = $ ( 'input#picker' ) ;
12
+ timeSelectDirectiveInput = $ ( 'input#picker' ) ;
15
13
datePickerPopup = $ ( this . popupSelector ) ;
16
- dayCalendar = $ ( `${ this . popupSelector } dp-day-calendar` ) ;
17
14
dayCalendarContainer = $ ( `${ this . popupSelector } dp-day-calendar .dp-day-calendar-container` ) ;
18
- monthPickerInput = $ ( '#monthPicker input' ) ;
15
+ monthPickerInput = $ ( '#picker input' ) ;
19
16
monthCalendar = $ ( `${ this . popupSelector } dp-month-calendar` ) ;
20
17
monthWeeks = $$ ( `${ this . popupSelector } .dp-calendar-week` ) ;
21
- calendarDays = $$ ( `${ this . popupSelector } .dp-calendar-day` ) ;
22
18
selectedDays = $$ ( `${ this . popupSelector } .dp-calendar-day.dp-selected` ) ;
23
19
selectedDay = $ ( `.dp-calendar-day.dp-selected` ) ;
24
20
selectedMonth = $ ( `.dp-calendar-month.dp-selected` ) ;
25
21
dayCalendarLeftNavBtn = $ ( `${ this . popupSelector } .dp-calendar-nav-left` ) ;
26
22
dayCalendarLeftSecondaryNavBtn = $ ( `${ this . popupSelector } .dp-calendar-secondary-nav-left` ) ;
27
- dayCalendarRightNavBtn = $ ( `${ this . popupSelector } .dp-calendar-nav-right` ) ;
28
23
dayCalendarRightSecondaryNavBtn = $ ( `${ this . popupSelector } .dp-calendar-secondary-nav-right` ) ;
29
24
monthCalendarLeftNavBtn = $ ( `${ this . popupSelector } dp-month-calendar .dp-calendar-nav-left` ) ;
30
25
monthCalendarRightNavBtn = $ ( `${ this . popupSelector } dp-month-calendar .dp-calendar-nav-right` ) ;
31
26
weekDayNames = $$ ( `${ this . popupSelector } .dp-weekdays` ) ;
32
- weekDayInline = $$ ( `.dp-demo-container .dp-weekdays` ) ;
33
- calendarContainer = $$ ( `${ this . popupSelector } .dp-calendar-container ` ) ;
27
+ weekDayInline = $$ ( `.dp-inline .dp-weekdays` ) ;
34
28
currentLocationBtn = $ ( `${ this . popupSelector } .dp-current-location-btn` ) ;
35
29
themeOnRadio = $ ( '#themeOn' ) ;
36
30
themeOffRadio = $ ( '#themeOff' ) ;
37
- openOnFocusRadioOn = $ ( '#yesOpenOnFocus' ) ;
38
31
openOnFocusRadioOff = $ ( '#noOpenOnFocus' ) ;
39
32
openOnClickRadioOn = $ ( '#yesOpenOnClick' ) ;
40
33
openOnClickRadioOff = $ ( '#noOpenOnClick' ) ;
41
34
onOpenDelayInput = $ ( '#onOpenDelay' ) ;
42
35
showNearMonthDaysRadio = $ ( '#showNearMonthDaysRadio' ) ;
43
36
hideNearMonthDaysRadio = $ ( '#hideNearMonthDaysRadio' ) ;
44
37
showWeekNumbersRadio = $ ( '#showWeekNumbersRadio' ) ;
45
- hideWeekNumbersRadio = $ ( '#hideWeekNumbersRadio' ) ;
46
38
weekNumbers = $$ ( `${ this . popupSelector } .dp-week-number` ) ;
47
39
dayCalendarNavHeaderBtn = $ ( `${ this . popupSelector } .dp-nav-header-btn` ) ;
48
40
deyCalendarMonthNavHeader = $ ( `${ this . popupSelector } dp-month-calendar .dp-nav-header` ) ;
@@ -54,12 +46,11 @@ export class DemoPage {
54
46
calendarDisabledDays = $$ ( `${ this . popupSelector } .dp-calendar-day[disabled]` ) ;
55
47
calendarFirstDayOfMonth = $$ ( `${ this . popupSelector } .dp-current-month` ) . get ( 0 ) ;
56
48
calendarFirstMonthOfYear = $$ ( `${ this . popupSelector } dp-month-calendar .dp-calendar-month` ) . get ( 0 ) ;
57
- calendarFirstMonthOfYearInline = $$ ( `.dp-demo-container dp-month-calendar .dp-calendar-month` ) . get ( 0 ) ;
49
+ calendarFirstMonthOfYearInline = $$ ( `.dp-inline dp-month-calendar .dp-calendar-month` ) . get ( 0 ) ;
58
50
59
51
currentMonthCalendarBtn = $ ( `${ this . popupSelector } dp-month-calendar .dp-current-month` ) ;
60
52
disableMonthSelector = $ ( '#disableMonthSelector' ) ;
61
53
yearFormat = $ ( '#yearFormat' ) ;
62
- localeOptions = $ ( '#locale' ) ;
63
54
hideGoToCurrentRadio = $ ( '#hideGoToCurrent' ) ;
64
55
showGoToCurrentRadio = $ ( '#showGoToCurrent' ) ;
65
56
enableUnselectSelected = $ ( '#enableUnSelect' ) ;
@@ -70,32 +61,23 @@ export class DemoPage {
70
61
disableRequiredValidationRadio = $ ( '#disableRequiredRadio' ) ;
71
62
requiredValidationMsg = $ ( '#requiredValidation' ) ;
72
63
formatValidationMsg = $ ( '#formatValidation' ) ;
73
- reactiveRequiredValidationMsg = $ ( '#reactiveRequiredValidation' ) ;
74
- reactiveMinDateValidationMsg = $ ( '#reactiveMinDateValidation' ) ;
75
- reactiveMaxDateValidationMsg = $ ( '#reactiveMaxDateValidation' ) ;
76
- timePickerMinTimeValidationMsg = $ ( '#timePickerMinTimeValidation' ) ;
77
- timePickerMaxTimeValidationMsg = $ ( '#timePickerMaxTimeValidation' ) ;
78
64
minDateValidationPickerInput = $ ( '#minDatePicker input' ) ;
79
65
minDateValidationMsg = $ ( '#minDateValidation' ) ;
80
66
maxDateValidationPickerInput = $ ( '#maxDatePicker input' ) ;
81
67
maxDateValidationMsg = $ ( '#maxDateValidation' ) ;
82
68
minTimeValidationPickerInput = $ ( '#minTimeValidation input' ) ;
83
- minTimeValidationMsg = $ ( '#minTimeValidation' ) ;
84
69
maxTimeValidationPickerInput = $ ( '#maxTimeValidation input' ) ;
85
- maxTimeValidationMsg = $ ( '#maxTimeValidation' ) ;
86
70
placeholderInput = $ ( '#placeholderInput' ) ;
87
71
firstDayOfWeekMonday = element ( by . cssContainingText ( '#firstDayOfWeekSelect option' , 'mo' ) ) ;
88
72
hebrewLocale = element ( by . cssContainingText ( '#locale option' , 'he' ) ) ;
89
73
monthFormatInput = $ ( '#monthFormatInput' ) ;
90
74
minSelectableInput = $ ( '#minSelectable input' ) ;
91
75
maxSelectableInput = $ ( '#maxSelectable input' ) ;
92
- closeOnSelect = $ ( '#closeOnSelect' ) ;
93
76
noCloseOnSelect = $ ( '#noCloseOnSelect' ) ;
94
77
closeDelayInput = $ ( '#closeDelay' ) ;
95
78
weekDaysFormatInput = $ ( '#weekDaysFormat' ) ;
96
79
dateFormatInput = $ ( '#dateFormat' ) ;
97
80
enableMultiselect = $ ( '#enableMultiselect' ) ;
98
- disableMultiselect = $ ( '#disableMultiselect' ) ;
99
81
dayBtnFormatInput = $ ( '#dayBtnFormat' ) ;
100
82
monthBtnFormatInput = $ ( '#monthBtnFormat' ) ;
101
83
@@ -109,14 +91,10 @@ export class DemoPage {
109
91
secondsFormatInput = $ ( '#secondsFormat' ) ;
110
92
secondsIntervalInput = $ ( '#secondsInterval' ) ;
111
93
showSeconds = $ ( '#showSeconds' ) ;
112
- hideSeconds = $ ( '#hideSeconds' ) ;
113
94
showTwentyFourHours = $ ( '#showTwentyFourHours' ) ;
114
- hideTwentyFourHours = $ ( '#hideTwentyFourHours' ) ;
115
95
timeSeparatorInput = $ ( '#timeSeparator' ) ;
116
96
showMultipleYearsNavigation = $ ( '#showMultipleYearsNavigation' ) ;
117
- hideMultipleYearsNavigation = $ ( '#hideMultipleYearsNavigation' ) ;
118
97
multipleYearsNavigateBy = $ ( '#multipleYearsNavigateBy' ) ;
119
- showInputRadio = $ ( '#showInputRadio' ) ;
120
98
hideInputRadio = $ ( '#hideInputRadio' ) ;
121
99
122
100
showOnOutsideClick = $ ( '#showOnOutsideClick' ) ;
@@ -134,7 +112,7 @@ export class DemoPage {
134
112
meridiemUpBtn = $ ( `${ this . popupSelector } .dp-time-select-control-meridiem > .dp-time-select-control-up` ) ;
135
113
meridiemDownBtn = $ ( `${ this . popupSelector } .dp-time-select-control-meridiem > .dp-time-select-control-down` ) ;
136
114
meridiemDisplay = $ ( `${ this . popupSelector } .dp-time-select-display-meridiem` ) ;
137
- meridiemDisplayInline = $ ( `.dp-demo-container .dp-time-select-display-meridiem` ) ;
115
+ meridiemDisplayInline = $ ( `.dp-inline .dp-time-select-display-meridiem` ) ;
138
116
timeSeparatorDisplay = $ ( `${ this . popupSelector } .dp-time-select-separator:nth-child(2)` ) ;
139
117
140
118
daytimePickerMenu = $ ( '#daytimePickerMenu' ) ;
@@ -143,7 +121,6 @@ export class DemoPage {
143
121
dayPickerMenu = $ ( '#dayPickerMenu' ) ;
144
122
dayInlineMenu = $ ( '#dayInlineMenu' ) ;
145
123
dayDirectiveMenu = $ ( '#dayDirectiveMenu' ) ;
146
- dayDirectiveReactiveMenu = $ ( '#dayDirectiveReactiveMenu' ) ;
147
124
monthPickerMenu = $ ( '#monthPickerMenu' ) ;
148
125
monthInlineMenu = $ ( '#monthInlineMenu' ) ;
149
126
monthDirectiveMenu = $ ( '#monthDirectiveMenu' ) ;
@@ -171,23 +148,38 @@ export class DemoPage {
171
148
}
172
149
173
150
clickOnDayButtonInline ( text : string ) {
174
- return element ( by . cssContainingText ( `.dp-inline-day .dp- calendar-day` , text ) ) . click ( ) ;
151
+ return element ( by . cssContainingText ( `.dp-calendar-day` , text ) ) . click ( ) ;
175
152
}
176
153
177
154
clickOnMonthButton ( text : string ) {
178
155
return element ( by . cssContainingText ( `${ this . popupSelector } .dp-calendar-month` , text ) ) . click ( ) ;
179
156
}
180
157
181
158
clickOnMonthButtonInline ( text : string ) {
182
- return element ( by . cssContainingText ( `.dp-inline-month .dp- calendar-month` , text ) ) . click ( ) ;
159
+ return element ( by . cssContainingText ( `.dp-calendar-month` , text ) ) . click ( ) ;
183
160
}
184
161
185
162
waitUntilPresent ( elem : ElementFinder ) {
186
163
return browser . wait ( ExpectedConditions . presenceOf ( elem ) , 5000 , 'Element taking too long to appear in the DOM' ) ;
187
164
}
188
165
166
+ async clearInput ( elem : ElementFinder ) : Promise < void > {
167
+ await elem . click ( ) ;
168
+ const keys = ( await elem . getAttribute ( 'value' ) ) . length ;
169
+ const tmpArr = [ ...Array ( keys ) ] . map ( ( ) => 0 ) ;
170
+ await elem . click ( ) ;
171
+
172
+ for ( const _ of tmpArr ) {
173
+ await elem . sendKeys ( protractor . Key . ARROW_RIGHT ) ;
174
+ }
175
+
176
+ for ( const _ of tmpArr ) {
177
+ await elem . sendKeys ( protractor . Key . BACK_SPACE ) ;
178
+ }
179
+ }
180
+
189
181
async setInputValue ( input : ElementFinder , val : string ) : Promise < void > {
190
- await input . clear ( ) ;
182
+ await this . clearInput ( input ) ;
191
183
await input . sendKeys ( val ) ;
192
184
}
193
185
}
0 commit comments