@@ -53,19 +53,17 @@ public void testSubscriptionHandlingWithLDAPEnabled() throws Exception {
53
53
// present AND there exists "edit" and" delete buttons" for unauthorized
54
54
// user "ABCD"
55
55
String response = getJSONStringFromFile (SUBSCRIPTION_FOR_RELOAD_TEST_FILE_PATH );
56
- String viewButtonXPath = "(//button[@id='view-Subscription1'])[2]" ;
57
- String editButtonXPath = "(//button[@id='edit-Subscription1'])[2]" ;
58
- String deleteButtonXPath = "(//button[@id='delete-Subscription1'])[2]" ;
59
- String expandButtonXPath = "//tr[contains(.,'Subscription1')]/td[1]" ;
60
56
61
57
subscriptionPage .clickReload (response );
62
58
63
- assert (subscriptionPage .textExistsInTable ("Subscription1" ));
64
- assert (subscriptionPage .textExistsInTable ("Subscription2" ));
65
- assert (subscriptionPage .clickElementByXPath (expandButtonXPath ));
66
- assert (subscriptionPage .buttonExist (deleteButtonXPath ));
67
- assert (subscriptionPage .buttonExist (editButtonXPath ));
68
- assert (subscriptionPage .buttonExist (viewButtonXPath ));
59
+ String expandButtonXPath = "//tr[contains(.,'Subscription1')]/td[1]" ;
60
+ String viewButtonXPath = "(//button[@id='view-Subscription1'])" ;
61
+ String editButtonXPath = "(//button[@id='edit-Subscription1'])" ;
62
+ String deleteButtonXPath = "(//button[@id='delete-Subscription1'])" ;
63
+ assert (subscriptionPage .clickExpandButtonByXPath (expandButtonXPath ));
64
+ assert (subscriptionPage .buttonExistByXPath (deleteButtonXPath ));
65
+ assert (subscriptionPage .buttonExistByXPath (editButtonXPath ));
66
+ assert (subscriptionPage .buttonExistByXPath (viewButtonXPath ));
69
67
70
68
// Given LDAP is enabled, "Reload" subscriptions and then click
71
69
// subscription page with LDAP enabled with unauthorized user names
@@ -76,10 +74,10 @@ public void testSubscriptionHandlingWithLDAPEnabled() throws Exception {
76
74
subscriptionPage .clickReloadLDAP (responseSub , responseAuth );
77
75
indexPageObject .clickSubscriptionPage ();
78
76
79
- assert (subscriptionPage .clickElementByXPath (expandButtonXPath ));
80
- assert (!subscriptionPage .buttonExist (deleteButtonXPath ));
81
- assert (!subscriptionPage .buttonExist (editButtonXPath ));
82
- assert (subscriptionPage .buttonExist (viewButtonXPath ));
77
+ assert (subscriptionPage .clickExpandButtonByXPath (expandButtonXPath ));
78
+ assert (!subscriptionPage .buttonExistByXPath (deleteButtonXPath ));
79
+ assert (!subscriptionPage .buttonExistByXPath (editButtonXPath ));
80
+ assert (subscriptionPage .buttonExistByXPath (viewButtonXPath ));
83
81
84
82
// Given LDAP is enabled, "Reload" subscriptions and then click
85
83
// subscription page with LDAP enabled with both unauthorized and
@@ -95,25 +93,26 @@ public void testSubscriptionHandlingWithLDAPEnabled() throws Exception {
95
93
indexPageObject .clickSubscriptionPage ();
96
94
97
95
assert (subscriptionPage .textExistsInTable ("Subscription1" ));
98
- assert (subscriptionPage .clickElementByXPath (expandButtonXPath ));
99
- assert (subscriptionPage .buttonExist (deleteButtonXPath ));
100
- assert (subscriptionPage .buttonExist (editButtonXPath ));
101
- assert (subscriptionPage .buttonExist (viewButtonXPath ));
96
+ assert (subscriptionPage .clickExpandButtonByXPath (expandButtonXPath ));
97
+ assert (subscriptionPage .buttonExistByXPath (deleteButtonXPath ));
98
+ assert (subscriptionPage .buttonExistByXPath (editButtonXPath ));
99
+ assert (subscriptionPage .buttonExistByXPath (viewButtonXPath ));
102
100
103
101
// Now, path for "subscriptions2" with user name "DEF", so user "ABCD"
104
102
// is unauthorized for this subscription
105
- String viewButtonXPath2 = "(//button[@id='view-Subscription2'])[2] " ;
106
- String editButtonXPath2 = "(//button[@id='edit-Subscription2'])[2] " ;
107
- String deleteButtonXPath2 = "(//button[@id='delete-Subscription2'])[2] " ;
103
+ String viewButtonXPath2 = "(//button[@id='view-Subscription2'])" ;
104
+ String editButtonXPath2 = "(//button[@id='edit-Subscription2'])" ;
105
+ String deleteButtonXPath2 = "(//button[@id='delete-Subscription2'])" ;
108
106
String expandButtonXPath2 = "//tr[contains(.,'Subscription2')]/td[1]" ;
109
107
110
- assert (subscriptionPage .clickElementByXPath (expandButtonXPath2 ));
111
- assert (subscriptionPage .buttonExist (viewButtonXPath2 ));
112
- assert (!subscriptionPage .buttonExist (editButtonXPath2 ));
113
- assert (!subscriptionPage .buttonExist (deleteButtonXPath2 ));
108
+ assert (subscriptionPage .clickExpandButtonByXPath (expandButtonXPath2 ));
109
+ assert (subscriptionPage .buttonExistByXPath (viewButtonXPath2 ));
110
+ subscriptionPage .clickViewButtonByXPath (viewButtonXPath2 );
111
+ assert (!subscriptionPage .buttonExistByXPath (editButtonXPath2 ));
112
+ assert (!subscriptionPage .buttonExistByXPath (deleteButtonXPath2 ));
114
113
115
114
// Test view button
116
- subscriptionPage .clickElementByXPath (viewButtonXPath2 );
115
+ subscriptionPage .clickViewButtonByXPath (viewButtonXPath2 );
117
116
assert (new WebDriverWait (driver , 10 )
118
117
.until ((webdriver ) -> driver .getPageSource ().contains ("View Subscription" )));
119
118
subscriptionPage .clickFormCloseBtn ();
@@ -163,29 +162,34 @@ public void testSubscriptionHandlingWithLDAPEnabled() throws Exception {
163
162
// On subscription form, select the template as "Mail Trigger" and
164
163
// verify
165
164
String selectID = "selectTemplate" ;
165
+ String mailRadioID = "mailRadio" ;
166
+ String notificationMetaInputID = "notificationMeta" ;
166
167
String tempMail = "Mail Trigger" ;
167
168
subscriptionPage .selectDropdown (selectID , tempMail );
168
- assert (new WebDriverWait (driver , 10 )
169
- .until ((webdriver ) -> (subscriptionPage .getValueFromSelect ().equals ("MAIL" ))));
170
- assert (new WebDriverWait (driver , 10 )
171
- .until ((webdriver ) -> (subscriptionPage .getValueFromElement ().equals ("mymail@company.com" ))));
169
+ assert (subscriptionPage .isRadioCheckboxSelected (mailRadioID ));
170
+ assertEquals ("mymail@company.com" , subscriptionPage .getValueFromElement (notificationMetaInputID ));
172
171
173
172
// On subscription form, select the template as "REST POST (Raw
174
173
// Body:JSON)" and verify
175
174
String tempPost = "REST POST (Raw Body : JSON)" ;
175
+ String restPostRadio = "restPostRadio" ;
176
+ String keyValueRadio = "keyValueRadio" ;
177
+ String appJsonRadio = "appJsonRadio" ;
176
178
subscriptionPage .selectDropdown (selectID , tempPost );
177
- assert (new WebDriverWait ( driver , 10 )
178
- . until (( webdriver ) -> ( subscriptionPage .getValueFromSelect (). equals ( "REST_POST" )) ));
179
- assert (new WebDriverWait ( driver , 10 ). until (
180
- ( webdriver ) -> ( subscriptionPage . getValueFromElement (). equals ( "http://<MyHost:port>/api/doit" )) ));
179
+ assert (subscriptionPage . isRadioCheckboxSelected ( restPostRadio ));
180
+ assert ( subscriptionPage .isRadioCheckboxSelected ( appJsonRadio ));
181
+ assert (! subscriptionPage . isRadioCheckboxSelected ( keyValueRadio ));
182
+ assertEquals ( "http://<MyHost:port>/api/doit" , subscriptionPage . getValueFromElement ( notificationMetaInputID ));
181
183
182
184
// On subscription form, select the template as "Jenkins Pipeline
183
- // Parameterized Job Trigger" and verify
185
+ // Parameterized Job Trigger" and verify RawBody unselected.
184
186
String tempJenkins = "Jenkins Pipeline Parameterized Job Trigger" ;
185
187
subscriptionPage .selectDropdown (selectID , tempJenkins );
186
- assertEquals ("REST_POST" , subscriptionPage .getValueFromSelect ());
188
+ assert (subscriptionPage .isRadioCheckboxSelected (restPostRadio ));
189
+ assert (subscriptionPage .isRadioCheckboxSelected (keyValueRadio ));
190
+ assert (!subscriptionPage .isRadioCheckboxSelected (appJsonRadio ));
187
191
assertEquals ("http://<JenkinsHost:port>/job/<JobName>/job/<branch>/build" ,
188
- subscriptionPage .getValueFromElement ());
192
+ subscriptionPage .getValueFromElement (notificationMetaInputID ));
189
193
190
194
// Choose Authorization as "Basic_AUTH" ===> input User Name as "ABCD"
191
195
// and Token as "EFGH" ===> click "Generate Key/Value Pair", verify the
@@ -196,43 +200,37 @@ public void testSubscriptionHandlingWithLDAPEnabled() throws Exception {
196
200
String userNameID = "userNameInput" ;
197
201
String password = "password" ;
198
202
String passwordID = "passwordInput" ;
199
- String subName = "Selenium_test_subscription" ;
200
- String subNameID = "subscriptionNameInput" ;
201
- String selectRepeatID = "selectRepeat" ;
202
- String repeatValue = "true" ;
203
- String conditionFieldID = "conditionID" ;
204
- String requirementFieldID = "requirementID" ;
205
-
206
203
subscriptionPage .selectDropdown (selectAuthID , authValue );
207
204
subscriptionPage .addFieldValue (userNameID , userName );
208
205
subscriptionPage .addFieldValue (passwordID , password );
209
206
210
207
assert (new WebDriverWait (driver , 10 ).until ((webdriver ) -> driver .getPageSource ().contains ("ABCD" )));
211
208
assert (new WebDriverWait (driver , 10 ).until ((webdriver ) -> driver .getPageSource ().contains ("password" )));
212
209
213
- // Test "Repeat" dropdown: Select repeat value as "true" and then verify the selected value
214
- subscriptionPage .selectDropdown (selectRepeatID , repeatValue );
215
- assert (new WebDriverWait (driver , 10 )
216
- .until ((webdriver ) -> (subscriptionPage .getValueFromSelectRepeat ().equals (repeatValue ))));
210
+ // Test "Repeat" checkbox: verify unchecked, then checked.
211
+ // NOTE: repeat checkbox is covered by a span, we click span
212
+ String checkboxRepeatID = "repeatCheckbox" ;
213
+ String spanId = "repeatCheckboxSpan" ;
214
+ assert (!subscriptionPage .isCheckboxSelected (checkboxRepeatID ));
215
+ subscriptionPage .clickSpanAroundCheckbox (checkboxRepeatID , spanId );
216
+ assert (subscriptionPage .isCheckboxSelected (checkboxRepeatID ));
217
217
218
218
// Test "Add Condition" button: click add condition button and check that it adds an additional "condition" field
219
+ String conditionFieldID = "conditionID" ;
219
220
subscriptionPage .clickAddConditionBtn ();
220
221
assertEquals (2 , subscriptionPage .countElements (conditionFieldID ));
221
222
222
223
// Test "Add Requirement" button: click the button and assert that it adds an additional "requirement" field
224
+ String requirementFieldID = "requirementID" ;
223
225
subscriptionPage .clickAddRequirementBtn ();
224
226
assertEquals (2 , subscriptionPage .countElements (requirementFieldID ));
225
227
226
- // Test "Repeat" dropdown: Select repeat value as "true" and then verify
227
- // the selected value
228
- subscriptionPage .selectDropdown (selectRepeatID , repeatValue );
229
- assert (new WebDriverWait (driver , 10 )
230
- .until ((webdriver ) -> (subscriptionPage .getValueFromSelectRepeat ().equals (repeatValue ))));
231
-
232
228
// Test save subscription form: add subscription name
233
229
// as "selenium_test_subscription" and then click "save" button
234
230
// verification that subscription is added in the datatable (and is
235
231
// displayed on the main page)
232
+ String subName = "Selenium_test_subscription" ;
233
+ String subNameID = "subscriptionNameInput" ;
236
234
String responseSave = getJSONStringFromFile (SUBSCRIPTION_FOR_SAVE_TEST_FILE_PATH );
237
235
subscriptionPage .addFieldValue (subNameID , subName );
238
236
subscriptionPage .clickFormsSaveBtn (responseSave );
0 commit comments