@@ -52,15 +52,17 @@ public void testSubscription() throws Exception {
52
52
// with names "Subscription1" and "Subscription2" are present AND there exists "edit" and
53
53
// "delete buttons" for unauthorized user "ABCD"
54
54
String response = this .getJSONStringFromFile (SUBSCRIPTION_FOR_RELOAD_TEST_FILE_PATH );
55
- String deleteButtonXPath = "//tr[td[contains(.,'Subscription1')]]/td/button[contains(text(),'Delete')]" ;
56
- String editButtonXPath = "//tr[td[contains(.,'Subscription1')]]/td/button[contains(text(),'Edit')]" ;
57
- String viewButtonXPath = "//tr[td[contains(.,'Subscription1')]]/td/button[contains(text(),'View')]" ;
55
+ String viewButtonXPath = "(//button[@id='view-Subscription1'])[2]" ;
56
+ String editButtonXPath = "(//button[@id='edit-Subscription1'])[2]" ;
57
+ String deleteButtonXPath = "(//button[@id='delete-Subscription1'])[2]" ;
58
+ String expandButtonXPath = "//tr[contains(.,'Subscription1')]/td[1]" ;
58
59
subscriptionPage .clickReload (response );
59
60
assert (subscriptionPage .textExistsInTable ("Subscription1" ));
60
61
assert (subscriptionPage .textExistsInTable ("Subscription2" ));
61
- assert (subscriptionPage .buttonExist (deleteButtonXPath ) == true );
62
- assert (subscriptionPage .buttonExist (editButtonXPath ) == true );
63
- assert (subscriptionPage .buttonExist (viewButtonXPath ) == true );
62
+ assert (subscriptionPage .clickElementByXPath (expandButtonXPath ));
63
+ assert (subscriptionPage .buttonExist (deleteButtonXPath ));
64
+ assert (subscriptionPage .buttonExist (editButtonXPath ));
65
+ assert (subscriptionPage .buttonExist (viewButtonXPath ));
64
66
65
67
// Given LDAP is enabled, "Reload" subscriptions and then click subscription
66
68
// page with LDAP enabled with unauthorized user names
@@ -69,9 +71,10 @@ public void testSubscription() throws Exception {
69
71
String responseAuth = "{\" security\" :true}" ;
70
72
subscriptionPage .clickReloadLDAP (responseSub , responseAuth );
71
73
indexPageObject .clickSubscriptionPage ();
72
- assert (subscriptionPage .buttonExist (deleteButtonXPath ) == false );
73
- assert (subscriptionPage .buttonExist (editButtonXPath ) == false );
74
- assert (subscriptionPage .buttonExist (viewButtonXPath ) == true );
74
+ assert (subscriptionPage .clickElementByXPath (expandButtonXPath ));
75
+ assert (!subscriptionPage .buttonExist (deleteButtonXPath ));
76
+ assert (!subscriptionPage .buttonExist (editButtonXPath ));
77
+ assert (subscriptionPage .buttonExist (viewButtonXPath ));
75
78
76
79
// Given LDAP is enabled, "Reload" subscriptions and then click subscription
77
80
// page with LDAP enabled with both unauthorized and unauthorized user names (in
@@ -85,21 +88,24 @@ public void testSubscription() throws Exception {
85
88
js .executeScript (String .format ("window.localStorage.setItem('%s','%s');" , keyForUser , valueForUser ));
86
89
indexPageObject .clickSubscriptionPage ();
87
90
assert (subscriptionPage .textExistsInTable ("Subscription1" ));
88
- assert (subscriptionPage .buttonExist (deleteButtonXPath ) == true );
89
- assert (subscriptionPage .buttonExist (editButtonXPath ) == true );
90
- assert (subscriptionPage .buttonExist (viewButtonXPath ) == true );
91
+ assert (subscriptionPage .clickElementByXPath (expandButtonXPath ));
92
+ assert (subscriptionPage .buttonExist (deleteButtonXPath ));
93
+ assert (subscriptionPage .buttonExist (editButtonXPath ));
94
+ assert (subscriptionPage .buttonExist (viewButtonXPath ));
91
95
92
96
// Now, path for "subscriptions2" with user name "DEF", so user "ABCD" is
93
97
// unauthorized for this subscription
94
- String deleteButtonXPath2 = "//tr[td[contains(.,'Subscription2')]]/td/button[contains(text(),'Delete')]" ;
95
- String editButtonXPath2 = "//tr[td[contains(.,'Subscription2')]]/td/button[contains(text(),'Edit')]" ;
96
- String viewButtonXPath2 = "//tr[td[contains(.,'Subscription2')]]/td/button[contains(text(),'View')]" ;
97
- assert (subscriptionPage .buttonExist (deleteButtonXPath2 ) == false );
98
- assert (subscriptionPage .buttonExist (editButtonXPath2 ) == false );
99
- assert (subscriptionPage .buttonExist (viewButtonXPath2 ) == true );
98
+ String viewButtonXPath2 = "(//button[@id='view-Subscription2'])[2]" ;
99
+ String editButtonXPath2 = "(//button[@id='edit-Subscription2'])[2]" ;
100
+ String deleteButtonXPath2 = "(//button[@id='delete-Subscription2'])[2]" ;
101
+ String expandButtonXPath2 = "//tr[contains(.,'Subscription2')]/td[1]" ;
102
+ assert (subscriptionPage .clickElementByXPath (expandButtonXPath2 ));
103
+ assert (subscriptionPage .buttonExist (viewButtonXPath2 ));
104
+ assert (!subscriptionPage .buttonExist (editButtonXPath2 ));
105
+ assert (!subscriptionPage .buttonExist (deleteButtonXPath2 ));
100
106
101
107
// Test view button
102
- subscriptionPage .clickViewBtn ( );
108
+ subscriptionPage .clickElementByXPath ( viewButtonXPath2 );
103
109
assert (new WebDriverWait (driver , 10 )
104
110
.until ((webdriver ) -> driver .getPageSource ().contains ("View Subscription" )));
105
111
subscriptionPage .clickFormCloseBtn ();
@@ -112,8 +118,8 @@ public void testSubscription() throws Exception {
112
118
// subscriptions are deleted
113
119
String mockedDeleteResponse = "" ;
114
120
subscriptionPage .clickBulkDelete (mockedDeleteResponse );
115
- assert (subscriptionPage .textExistsInTable ("Subscription1" ) == false );
116
- assert (subscriptionPage .textExistsInTable ("Subscription2" ) == false );
121
+ assert (! subscriptionPage .textExistsInTable ("Subscription1" ));
122
+ assert (! subscriptionPage .textExistsInTable ("Subscription2" ));
117
123
118
124
// Verify that "get template" button works
119
125
String mockedTemplateResponse = this .getJSONStringFromFile (SUBSCRIPTION_TEMPLATE_FILE_PATH );
0 commit comments