14
14
15
15
public class SubscriptionPage extends PageBaseClass {
16
16
private static final String ROUTE = "/#subscriptions" ;
17
+ private static final String ADD_SUBSCRIPTION_BUTTON_ID = "addSubscription" ;
18
+ private static final String FORM_CANCEL_BUTTON_ID = "btnFormCancel" ;
19
+ private static final String CHECK_ALL_BUTTON_ID = "check-all" ;
20
+ private static final String RELOAD_BUTTON_ID = "reloadButton" ;
21
+ private static final String SAVE_BUTTON_ID = "btnSave" ;
22
+ private static final String GET_TEMPLATE_BUTTON_ID = "getTemplateButton" ;
23
+ private static final String BULK_DOWNLOAD_BUTTON_ID = "bulkDownload" ;
24
+ private static final String ADD_CONDITION_BUTTON_ID = "addCondition" ;
25
+ private static final String ADD_REQUIREMENT_BUTTON_ID = "addRequirement" ;
26
+ private static final String BULK_DELETE_BUTTON_ID = "bulkDelete" ;
27
+ private static final String CLOSE_BUTTON_CLASS_NAME = "close" ;
17
28
18
29
public SubscriptionPage (CloseableHttpClient mockedHttpClient , FirefoxDriver driver , String baseUrl )
19
30
throws IOException {
@@ -35,50 +46,75 @@ public boolean presenceOfHeader(String loc) {
35
46
}
36
47
}
37
48
49
+ /*
50
+ * Button clicking start.
51
+ */
52
+
38
53
public void clickAddSubscription () {
39
- WebElement addSubscriptionBtn = new WebDriverWait (driver , TIMEOUT_TIMER ).until (
40
- ExpectedConditions .elementToBeClickable (By .id ("addSubscription" )));
41
- addSubscriptionBtn .click ();
54
+ clickButtonById (ADD_SUBSCRIPTION_BUTTON_ID );
42
55
}
43
56
44
57
public void clickFormsCancelBtn () {
45
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id ("btnFormCancel" )));
46
- WebElement cancelBtn = driver .findElement (By .id ("btnFormCancel" ));
47
- cancelBtn .click ();
58
+ clickButtonById (FORM_CANCEL_BUTTON_ID );
48
59
}
49
60
50
- public void clickBulkDelete () throws IOException {
51
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id ("check-all" )));
52
- WebElement checkbox = driver .findElement (By .id ("check-all" ));
53
- checkbox .click ();
61
+ public void clickCheckAll () {
62
+ clickButtonById (CHECK_ALL_BUTTON_ID );
63
+ }
64
+
65
+ public void clickReload () {
66
+ clickButtonById (RELOAD_BUTTON_ID );
67
+ }
54
68
55
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id ("bulkDelete" )));
56
- WebElement bulkDeleteBtn = driver .findElement (By .id ("bulkDelete" ));
57
- bulkDeleteBtn .click ();
69
+ public void clickFormsSaveBtn () {
70
+ clickButtonById (SAVE_BUTTON_ID );
71
+ }
72
+
73
+ public void clickGetTemplate () {
74
+ clickButtonById (GET_TEMPLATE_BUTTON_ID );
75
+ }
76
+
77
+ public void clickBulkDownload () {
78
+ clickButtonById (BULK_DOWNLOAD_BUTTON_ID );
79
+ }
80
+
81
+ public void clickAddConditionBtn () {
82
+ clickButtonById (ADD_CONDITION_BUTTON_ID );
83
+ }
84
+
85
+ public void clickAddRequirementBtn () {
86
+ clickButtonById (ADD_REQUIREMENT_BUTTON_ID );
87
+ }
88
+
89
+ public void clickReloadLDAP () {
90
+ clickButtonById (RELOAD_BUTTON_ID );
91
+ }
92
+
93
+ public void clickBulkDelete () throws IOException {
94
+ clickButtonById (BULK_DELETE_BUTTON_ID );
58
95
// Click confirm button to confirm delete
59
96
new WebDriverWait (driver , TIMEOUT_TIMER ).until (
60
97
ExpectedConditions .elementToBeClickable (By .cssSelector (".confirm-delete .modal-footer .btn-danger" )));
61
98
WebElement confirmBtn = driver .findElement (By .cssSelector (".confirm-delete .modal-footer .btn-danger" ));
62
99
confirmBtn .click ();
63
100
}
64
101
65
- public void clickReload () {
66
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id ("reloadButton" )));
67
- WebElement reloadBtn = driver .findElement (By .id ("reloadButton" ));
68
- reloadBtn .click ();
102
+ public void clickButtonById (String id ) {
103
+ new WebDriverWait (driver , TIMEOUT_TIMER ).until (
104
+ ExpectedConditions .elementToBeClickable (By .id (id )));
105
+ WebElement button = driver .findElement (By .id (id ));
106
+ button .click ();
69
107
}
70
108
71
- public void clickFormsSaveBtn () throws IOException {
72
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id ( "btnSave" )));
73
- WebElement saveBtn = driver .findElement (By .id ( "btnSave" ));
74
- saveBtn .click ();
109
+ public void clickFormCloseBtn () {
110
+ new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .className ( CLOSE_BUTTON_CLASS_NAME )));
111
+ WebElement formCloseButton = driver .findElement (By .className ( CLOSE_BUTTON_CLASS_NAME ));
112
+ formCloseButton .click ();
75
113
}
76
114
77
- public void clickKVbtn (String loc ) {
78
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id (loc )));
79
- WebElement kvBtn = driver .findElement (By .id (loc ));
80
- kvBtn .click ();
81
- }
115
+ /*
116
+ * Button clicking stop.
117
+ */
82
118
83
119
public void selectDropdown (String loc , String value ) {
84
120
new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id (loc )));
@@ -142,32 +178,6 @@ public boolean presenceOfClickGetTemplateButton() {
142
178
}
143
179
}
144
180
145
- public void clickGetTemplate () {
146
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (
147
- ExpectedConditions .elementToBeClickable (By .id ("getTemplateButton" )));
148
- WebElement getTemplateButton = driver .findElement (By .id ("getTemplateButton" ));
149
- getTemplateButton .click ();
150
- }
151
-
152
- public void clickFormCloseBtn () {
153
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .className ("close" )));
154
- WebElement viewBtn = driver .findElement (By .className ("close" ));
155
- viewBtn .click ();
156
- }
157
-
158
- public void clickAddConditionBtn () {
159
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (ExpectedConditions .elementToBeClickable (By .id ("addCondition" )));
160
- WebElement viewBtn = driver .findElement (By .id ("addCondition" ));
161
- viewBtn .click ();
162
- }
163
-
164
- public void clickAddRequirementBtn () {
165
- new WebDriverWait (driver , TIMEOUT_TIMER ).until (
166
- ExpectedConditions .elementToBeClickable (By .id ("addRequirement" )));
167
- WebElement viewBtn = driver .findElement (By .id ("addRequirement" ));
168
- viewBtn .click ();
169
- }
170
-
171
181
public String getSubscriptionNameFromSubscription () {
172
182
new WebDriverWait (driver , TIMEOUT_TIMER ).until (
173
183
ExpectedConditions .elementToBeClickable (By .xpath ("//tr[@class='odd']/td[3]" )));
@@ -186,8 +196,7 @@ public boolean expandButtonExist(String XPath) {
186
196
187
197
public boolean buttonExistByXPath (String XPath ) {
188
198
// The row indicates weather or not the del / view and edit buttons has moved
189
- // down to
190
- // next row.
199
+ // down to next row.
191
200
String findInRow ;
192
201
try {
193
202
findInRow = "[2]" ;
@@ -217,12 +226,6 @@ public boolean buttonDisabledByXPath(String XPath) {
217
226
}
218
227
}
219
228
220
- public void clickReloadLDAP () throws IOException {
221
- WebElement reloadBtn = new WebDriverWait (driver , TIMEOUT_TIMER ).until (
222
- ExpectedConditions .elementToBeClickable (By .id ("reloadButton" )));
223
- reloadBtn .click ();
224
- }
225
-
226
229
public boolean textExistsInTable (String txt ) {
227
230
try {
228
231
new WebDriverWait (driver , TIMEOUT_TIMER ).until (
@@ -263,7 +266,7 @@ public int countElements(String id) {
263
266
.size ();
264
267
}
265
268
266
- public void clickViewButtonByXPath (String XPath ) {
269
+ public void clickButtonByXPath (String XPath ) {
267
270
// The row indicates weather or not the del / view and edit buttons has moved
268
271
// down to
269
272
// next row.
@@ -293,5 +296,4 @@ public boolean noPresenceOfHeader(String loc) {
293
296
return false ;
294
297
}
295
298
}
296
-
297
299
}
0 commit comments