From e3b43f02b142957672ed92d66d4a9766c7e5d133 Mon Sep 17 00:00:00 2001 From: Attila Vamos Date: Wed, 8 Jan 2025 15:42:05 +0000 Subject: [PATCH] HPCC-33041 ECL Watch UI test (GH Action) reports an error with 'Files' page. ActivitiesTest.java: - Change the 'should match' behaviour to a 'looks like' attempt when the test tries to identify a WEB page where it is landed after clicked a hyperlink.. test-ui-gh_runner.yml: - Change Chromedriver vesion (PR-19330 not merged yet) - Fix the tests log artifact name Tested locally. Signed-off-by: Attila Vamos --- .../tests/framework/pages/ActivitiesTest.java | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/esp/src/test-ui/tests/framework/pages/ActivitiesTest.java b/esp/src/test-ui/tests/framework/pages/ActivitiesTest.java index 9229481f79a..5949ccf245a 100644 --- a/esp/src/test-ui/tests/framework/pages/ActivitiesTest.java +++ b/esp/src/test-ui/tests/framework/pages/ActivitiesTest.java @@ -42,16 +42,25 @@ private void testForNavigationLinks(List 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); @@ -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 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 getNavWebElements() {