Skip to content

Commit

Permalink
Merge pull request #19341 from AttilaVamos/HPCC-33041-fix-master
Browse files Browse the repository at this point in the history
HPCC-33041 ECL Watch UI test (GH Action) reports an error with 'Files' page.

Reviewed-By: Chris Lo
Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Jan 10, 2025
2 parents 32fdef5 + e3b43f0 commit 2618f6f
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions esp/src/test-ui/tests/framework/pages/ActivitiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,25 @@ private void testForNavigationLinks(List<NavigationWebElement> navWebElements) {

for (NavigationWebElement element : navWebElements) {

StringBuilder errorMsg = new StringBuilder("OK");

try {
element.webElement().click();

if (testTabsForNavigationLinks(element)) {
if (testTabsForNavigationLinks(element, errorMsg)) {
String msg = "Success: Navigation Menu Link for " + element.name() + ". URL : " + element.hrefValue();
Common.logDetail(msg);
if ( errorMsg.length() > 0 ){
String currentPage = getCurrentPage();
String warningMsg = " Warning: on '" + currentPage + "' page there is missing/not matching element(s):" + errorMsg;
Common.logDetail(warningMsg);
}
} else {
// Needs to report why it is failed
String currentPage = getCurrentPage();
String errorMsg = "Failure: Navigation Menu Link for " + element.name() + " page failed. The current navigation page that we landed on is " + currentPage + ". Current URL : " + element.hrefValue();
Common.logError(errorMsg);
String failureMsg = "Failure: Navigation Menu Link for " + element.name() + " page failed. The current navigation page that we landed on is " + currentPage + ". Current URL : " + element.hrefValue() + ". Missing element(s): " + errorMsg;
Common.logError(failureMsg);
// Needs to log the error into the logDetails as well.
}
} catch (Exception ex) {
Common.logException("Failure: Exception in Navigation Link for " + element.name() + ". URL : " + element.hrefValue() + " Error: " + ex.getMessage(), ex);
Expand Down Expand Up @@ -80,19 +89,33 @@ private String getCurrentPage() {
return "Invalid Page";
}

private boolean testTabsForNavigationLinks(NavigationWebElement element) {
private boolean testTabsForNavigationLinks(NavigationWebElement element, StringBuilder msg) {
msg.delete(0, msg.length());
boolean retVal = true;

List<String> tabsList = URLConfig.tabsListMap.get(element.name());
int numOfElements = tabsList.size();
if ( numOfElements == 0 ) {
return retVal;
}

double elementFound = 0.0; // It is double for calculating ratio later.

for (String tab : tabsList) {
try {
WebElement webElement = Common.waitForElement(By.xpath("//a[text()='" + tab + "']"));
urlMap.get(element.name()).getUrlMappings().put(tab, new URLMapping(tab, webElement.getAttribute("href")));
elementFound += 1.0;
} catch (TimeoutException ex) {
return false;
msg.append("'" + tab + "', ");
}
}

return true;

if ( (elementFound / numOfElements) < 0.5 ) {
retVal = false;
}
Common.logDebug("In testTabsForNavigationLinks(element = '" + element.name() + "') -> numOfElements:" + numOfElements + ", elementFound:" + elementFound + ", ratio: " + (elementFound / numOfElements) + ", retVal:" + retVal + "." );
return retVal;
}

private List<NavigationWebElement> getNavWebElements() {
Expand Down

0 comments on commit 2618f6f

Please sign in to comment.