From ec0bba7ac7b8961572773803fce6d55ef8d2a294 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Thu, 25 Mar 2021 15:25:01 +0200 Subject: [PATCH 1/3] add fix for failing tests activateModel and deactivateModel() --- .../common/WebElementInteraction.java | 29 +++++++++++++------ .../DialogPages/ImportModelDialog.java | 2 ++ .../modelManager/ModelActionsComponent.java | 12 ++++---- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/common/WebElementInteraction.java b/alfresco-tas-share-test/src/main/java/org/alfresco/common/WebElementInteraction.java index b778c91d29..42fff4f438 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/common/WebElementInteraction.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/common/WebElementInteraction.java @@ -438,20 +438,20 @@ protected WebElement waitUntilElementIsPresent(By locator) } } - protected WebElement waitUntilChildElementIsPresent(By parentLocator, By childLocator) + protected WebElement waitUntilChildElementIsPresent(By parentLocator, By childLocator, long secondsToWait) { try { - return setWaitingTime(getDefaultProperties().getExplicitWait(), getDefaultProperties().getPollingTimeInMillis()) - .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); + return setWaitingTime(secondsToWait, getDefaultProperties().getPollingTimeInMillis()) + .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); } catch (NoSuchElementException | StaleElementReferenceException | ElementNotInteractableException | TimeoutException exception) { try { log.warn("Unable to find parent locator {} with child {}", parentLocator, childLocator); - return setWaitingTime(getDefaultProperties().getExplicitWait(), getDefaultProperties().getPollingTimeInMillis()) - .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); + return setWaitingTime(secondsToWait, getDefaultProperties().getPollingTimeInMillis()) + .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); } catch (ElementNotVisibleException elementNotVisibleException) { @@ -462,18 +462,24 @@ protected WebElement waitUntilChildElementIsPresent(By parentLocator, By childLo } } - protected WebElement waitUntilChildElementIsPresent(WebElement parentLocator, By childLocator) { + protected WebElement waitUntilChildElementIsPresent(By parentLocator, By childLocator) + { + return waitUntilChildElementIsPresent(parentLocator, childLocator, getDefaultProperties().getExplicitWait()); + } + + protected WebElement waitUntilChildElementIsPresent(WebElement parentLocator, By childLocator, long waitInSeconds) + { try { - return setWaitingTime(getDefaultProperties().getExplicitWait(), getDefaultProperties().getPollingTimeInMillis()) - .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); + return setWaitingTime(waitInSeconds, getDefaultProperties().getPollingTimeInMillis()) + .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); } catch (NoSuchElementException | StaleElementReferenceException | ElementNotInteractableException | TimeoutException exception) { try { log.warn("Unable to find parent locator {} with child {}", parentLocator, childLocator); - return setWaitingTime(getDefaultProperties().getExplicitWait(), getDefaultProperties().getPollingTimeInMillis()) + return setWaitingTime(waitInSeconds, getDefaultProperties().getPollingTimeInMillis()) .until(ExpectedConditions.presenceOfNestedElementLocatedBy(parentLocator, childLocator)); } catch (NoSuchElementException noSuchElementException) @@ -485,6 +491,11 @@ protected WebElement waitUntilChildElementIsPresent(WebElement parentLocator, By } } + protected WebElement waitUntilChildElementIsPresent(WebElement parentLocator, By childLocator) + { + return waitUntilChildElementIsPresent(parentLocator, childLocator, getDefaultProperties().getExplicitWait()); + } + protected List waitUntilElementsAreVisible(By locator) { try diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java index 8291ed5182..6db3d5bf3c 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java @@ -63,6 +63,8 @@ public ModelManagerPage clickImportButton() waitUntilElementDisappears(importModelWindow); ModelManagerPage modelManagerPage = new ModelManagerPage(webDriver); modelManagerPage.waitForContentModelTableToBeLoaded(); + waitInSeconds(1); + return modelManagerPage; } } diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java index 0ce610bded..cde26daa19 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java @@ -1,6 +1,7 @@ package org.alfresco.po.share.user.admin.adminTools.modelManager; import static org.alfresco.common.RetryTime.RETRY_TIME_15; +import static org.alfresco.common.Wait.WAIT_2; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; @@ -12,10 +13,7 @@ import org.alfresco.rest.model.RestCustomTypeModel; import org.alfresco.utility.model.CustomAspectModel; import org.alfresco.utility.model.CustomContentModel; -import org.openqa.selenium.By; -import org.openqa.selenium.StaleElementReferenceException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; +import org.openqa.selenium.*; /** * @author Bogdan Bocancea @@ -168,13 +166,15 @@ private void waitForContentModelStatus(By modelStatus) { try { - waitUntilChildElementIsPresent(getModelRow(), modelStatus); + waitForContentModelTableToBeLoaded(); + waitUntilChildElementIsPresent(getModelRow(), modelStatus, WAIT_2.getValue()); break; } - catch (StaleElementReferenceException e) + catch (StaleElementReferenceException | TimeoutException e) { log.error("Wait for custom model status to change"); retryCounter++; + continue; } } } From de37a2a789d65766eb8b36db8432cd004588066f Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Thu, 25 Mar 2021 15:32:44 +0200 Subject: [PATCH 2/3] update wait in clickImportButton() method --- .../user/admin/adminTools/DialogPages/ImportModelDialog.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java index 6db3d5bf3c..6dee02b6a1 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/DialogPages/ImportModelDialog.java @@ -2,6 +2,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.alfresco.common.Wait.WAIT_1; import org.alfresco.po.share.BaseDialogComponent; import org.alfresco.po.share.user.admin.adminTools.modelManager.ModelManagerPage; @@ -63,7 +64,7 @@ public ModelManagerPage clickImportButton() waitUntilElementDisappears(importModelWindow); ModelManagerPage modelManagerPage = new ModelManagerPage(webDriver); modelManagerPage.waitForContentModelTableToBeLoaded(); - waitInSeconds(1); + waitInSeconds(WAIT_1.getValue()); return modelManagerPage; } From cfc619d790a8fe869d9c65d91360d2b3b2622f08 Mon Sep 17 00:00:00 2001 From: Bogdan Bocancea Date: Thu, 25 Mar 2021 15:36:36 +0200 Subject: [PATCH 3/3] update while() in waitForContentModelStatus method --- .../adminTools/modelManager/ModelActionsComponent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java index cde26daa19..c396eea9b7 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/user/admin/adminTools/modelManager/ModelActionsComponent.java @@ -1,6 +1,7 @@ package org.alfresco.po.share.user.admin.adminTools.modelManager; import static org.alfresco.common.RetryTime.RETRY_TIME_15; +import static org.alfresco.common.Wait.WAIT_1; import static org.alfresco.common.Wait.WAIT_2; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -167,14 +168,13 @@ private void waitForContentModelStatus(By modelStatus) try { waitForContentModelTableToBeLoaded(); - waitUntilChildElementIsPresent(getModelRow(), modelStatus, WAIT_2.getValue()); + waitUntilChildElementIsPresent(getModelRow(), modelStatus, WAIT_1.getValue()); + retryCounter++; break; } catch (StaleElementReferenceException | TimeoutException e) { log.error("Wait for custom model status to change"); - retryCounter++; - continue; } } }