Skip to content

Commit fa45317

Browse files
Bug ei frontend subscription (#51)
* code changes 9561 * formatting * reviewed changes * changing port number as it was before * added spacing for Authorizationjusted * Create EI Frontend Test Framework * Create EI Frontend Test Framework with Selenium test framework (using Firefox driver). * This test framework will be used for EI Frontend Functional Tests. * Support for Travis-CI * Sample test case * Fix issue with selenium test sometimes fails * Fix geckodriver filepermissions * Fix logging * Remove unnecessary code * Add support for parallel test execution * Work in progress for restructuring mocking * update test * try * Fix mocking the bridge - Created a case were we show how to mock the bridge, has some issues with timing. * Fix timing issues * on going * adding more tests * changes * template_upload test needed to be done and time delays need to be removed * merging to master * commiting local before pull * merging * in the middle * working * Functional Test for Subscription * removal of unncessary code * back to headless mode * some reviewed changes * xpath to ids * view functionality * a small change for wait * some changes * complete * complete * set port number to 8080 * set port number to 8080 * set port number to 8080 * FT Subscription with LDAP * LDAP enabled Subscription page * merging * removed some commented code * removed some commented code * minors * merging * reviwed changes * reviewed changes
1 parent 0e89adf commit fa45317

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/functionaltest/java/com/ericsson/ei/frontend/SubscriptionHandlingFunctionality.java

+7-14
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ public void testSubscription() throws Exception {
5656
String editButtonXPath = "//tr[td[contains(.,'Subscription1')]]/td/button[contains(text(),'Edit')]";
5757
String viewButtonXPath = "//tr[td[contains(.,'Subscription1')]]/td/button[contains(text(),'View')]";
5858
subscriptionPage.clickReload(response);
59-
assert (new WebDriverWait(driver, 10)
60-
.until((webdriver) -> ((driver.getPageSource().contains("Subscription1")))));
61-
assert (new WebDriverWait(driver, 10)
62-
.until((webdriver) -> ((driver.getPageSource().contains("Subscription2")))));
59+
assert (subscriptionPage.textExistsInTable("Subscription1"));
60+
assert (subscriptionPage.textExistsInTable("Subscription2"));
6361
assert (subscriptionPage.buttonExist(deleteButtonXPath) == true);
6462
assert (subscriptionPage.buttonExist(editButtonXPath) == true);
6563
assert (subscriptionPage.buttonExist(viewButtonXPath) == true);
@@ -86,8 +84,7 @@ public void testSubscription() throws Exception {
8684
js = ((JavascriptExecutor) driver);
8785
js.executeScript(String.format("window.localStorage.setItem('%s','%s');", keyForUser, valueForUser));
8886
indexPageObject.clickSubscriptionPage();
89-
assert (new WebDriverWait(driver, 10)
90-
.until((webdriver) -> ((driver.getPageSource().contains("Subscription1")))));
87+
assert (subscriptionPage.textExistsInTable("Subscription1"));
9188
assert (subscriptionPage.buttonExist(deleteButtonXPath) == true);
9289
assert (subscriptionPage.buttonExist(editButtonXPath) == true);
9390
assert (subscriptionPage.buttonExist(viewButtonXPath) == true);
@@ -115,10 +112,8 @@ public void testSubscription() throws Exception {
115112
// subscriptions are deleted
116113
String mockedDeleteResponse = "";
117114
subscriptionPage.clickBulkDelete(mockedDeleteResponse);
118-
assert (new WebDriverWait(driver, 10)
119-
.until((webdriver) -> ((driver.getPageSource().contains("Subscription1")) == false)));
120-
assert (new WebDriverWait(driver, 10)
121-
.until((webdriver) -> ((driver.getPageSource().contains("Subscription2")) == false)));
115+
assert (subscriptionPage.textExistsInTable("Subscription1") == false);
116+
assert (subscriptionPage.textExistsInTable("Subscription2") == false);
122117

123118
// Verify that "get template" button works
124119
String mockedTemplateResponse = this.getJSONStringFromFile(SUBSCRIPTION_TEMPLATE_FILE_PATH);
@@ -132,8 +127,7 @@ public void testSubscription() throws Exception {
132127
// SUbscriptions" button and verify
133128
String mockedUploadResponse = this.getJSONStringFromFile(SUBSCRIPTION_FOR_UPLOAD_FILE_PATH);
134129
subscriptionPage.clickUploadSubscriptionFunctionality(DOWNLOADED_TEMPLATE_FILE_PATH, mockedUploadResponse);
135-
assert (new WebDriverWait(driver, 10)
136-
.until((webdriver) -> (driver.getPageSource().contains("Subscription_uploaded"))));
130+
assert (subscriptionPage.textExistsInTable("Subscription_uploaded"));
137131

138132
// Click "Add Subscription" button and verify that "Subscription Form" is open
139133
subscriptionPage.clickAddSubscription();
@@ -192,7 +186,6 @@ public void testSubscription() throws Exception {
192186
String responseSave = this.getJSONStringFromFile(SUBSCRIPTION_FOR_SAVE_TEST_FILE_PATH);
193187
subscriptionPage.addFieldValue(subNameID, subName);
194188
subscriptionPage.clickFormsSaveBtn(responseSave);
195-
assert (new WebDriverWait(driver, 10)
196-
.until((webdriver) -> driver.getPageSource().contains("Selenium_test_subscription")));
189+
assert (subscriptionPage.textExistsInTable("Selenium_test_subscription"));
197190
}
198191
}

src/functionaltest/java/com/ericsson/ei/frontend/pageobjects/SubscriptionPage.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public void clickBulkDelete(String response) throws IOException {
5757
.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(),'confirm')]")));
5858
WebElement confirmBtn = driver.findElement(By.xpath("//button[contains(text(),'confirm')]"));
5959
confirmBtn.click();
60-
6160
}
6261

6362
public void clickReload(String response) throws IOException {
@@ -172,7 +171,7 @@ public String getSubscriptionNameFromSubscription() {
172171
return subscriptionNameElement.getText();
173172
}
174173

175-
public Boolean buttonExist(String loc) {
174+
public boolean buttonExist(String loc) {
176175
try {
177176
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.xpath(loc)));
178177
} catch (Exception e) {
@@ -192,4 +191,13 @@ public void clickReloadLDAP(String response, String responseAuth) throws IOExcep
192191
.until(ExpectedConditions.elementToBeClickable(By.id("reloadButton")));
193192
reloadBtn.click();
194193
}
194+
195+
public boolean textExistsInTable(String txt) {
196+
try {
197+
new WebDriverWait(driver, TIMEOUT_TIMER).until(ExpectedConditions.elementToBeClickable(By.xpath("//tr[td[contains(.,'" +txt+ "')]]")));
198+
} catch (Exception e) {
199+
return false;
200+
}
201+
return true;
202+
}
195203
}

src/main/resources/templates/subscription.html

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<meta name="description" content=""/>
88
<meta name="author" content=""/>
99

10-
1110
<title>Eiffel Intelligence Subscription Handling</title>
1211

1312
</head>
@@ -132,7 +131,6 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
132131
</div>
133132
</div>
134133

135-
136134
<div class="pb-3 border border-primary form-group">
137135
<label class="pl-1 control-label font-weight-bold">NotificationMessage</label>
138136

@@ -149,8 +147,7 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
149147
<td data-bind="visible: $root.formpostkeyvaluepairs">
150148
<input data-toggle="tooltip" title="Specify a Key" data-bind="textInput:$data.formkey" name="formkey"
151149
placeholder="Key" class="form-control" type="text"/>
152-
</td>
153-
150+
</td>
154151
<td>
155152
<textarea data-toggle="tooltip" title="Choose a notification message" data-bind="textInput:$data.formvalue"
156153
name="formvalue" placeholder="Value" class="form-control" type="text"></textarea>
@@ -187,13 +184,16 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
187184
<div class="pb-3 border border-primary form-group" data-bind="visible: authenticationType() == 'BASIC_AUTH'">
188185
<label class="pl-1 control-label font-weight-bold">User Name*</label>
189186
<div>
187+
190188
<input id="userNameInput" data-toggle="tooltip" title="Enter user name" data-bind="textInput:$data.userName" name="userName" placeholder="userName" class="form-control" type="text" />
189+
191190
<span class="help-block"></span>
192191
</div>
193192

194193
<label class="pl-1 control-label font-weight-bold">Token*</label>
195194
<div>
196195
<input id="tokenInput" data-toggle="tooltip" title="Enter token" data-bind="textInput:$data.token" name="token" placeholder="token" class="form-control" type="password" />
196+
197197
<span class="help-block"></span>
198198
</div>
199199

@@ -273,7 +273,6 @@ <h3 class="modal-title text-center" id="formHeader">Subscription Form</h3>
273273
</button>
274274
</div>
275275

276-
277276
<!-- /ko -->
278277

279278
</div>

0 commit comments

Comments
 (0)