From e45b6865f542d37d76a36e3c94329a042494c385 Mon Sep 17 00:00:00 2001 From: Vu Tong <129731357+tphvu-axonivy@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:11:52 +0700 Subject: [PATCH] IVYPORTAL-17542-Use-latest-web-tester-to-run-all-tests (#1109) - update to ivy web-tester 11.3.0 - update proper api usage --- .../portal-selenium-test/customized_pom.xml | 2 +- .../document_screenshot_pom.xml | 2 +- AxonIvyPortal/portal-selenium-test/pom.xml | 2 +- .../selenium/common/ComplexFilterHelper.java | 3 ++- .../portal/selenium/page/AbsencePage.java | 10 ++++---- .../portal/selenium/page/CaseDetailsPage.java | 21 ++++++++-------- .../portal/selenium/page/ChatPage.java | 3 +-- .../page/DashboardConfigurationPage.java | 13 ++++++++-- .../page/DashboardNewsWidgetPage.java | 3 ++- .../selenium/page/LeaveRequestIFramePage.java | 7 +++--- .../selenium/page/LeaveRequestPage.java | 7 +++--- .../selenium/page/NewDashboardPage.java | 4 +--- .../portal/selenium/page/NoteHistoryPage.java | 6 ++--- .../ProcessEditWidgetNewDashBoardPage.java | 2 +- .../selenium/page/ProcessWidgetPage.java | 24 +++++++++---------- .../selenium/page/ReorderDashboardPage.java | 17 +++++++++---- .../selenium/page/RoleManagementPage.java | 2 +- .../selenium/page/SearchResultPage.java | 3 ++- .../portal/selenium/page/TaskDetailsPage.java | 8 +++---- .../selenium/page/TaskIFrameTemplatePage.java | 4 ++-- .../selenium/page/TaskTemplatePage.java | 4 ++-- .../portal/selenium/page/TaskWidgetPage.java | 12 +++++----- .../portal/selenium/page/TemplatePage.java | 7 +++--- .../selenium/page/TopMenuTaskWidgetPage.java | 4 ++-- .../WelcomeEditWidgetNewDashboardPage.java | 5 ++-- .../DashboardRestoreConfigurationTest.java | 3 ++- 26 files changed, 96 insertions(+), 82 deletions(-) diff --git a/AxonIvyPortal/portal-selenium-test/customized_pom.xml b/AxonIvyPortal/portal-selenium-test/customized_pom.xml index b1fb75716e7..09309492b2a 100644 --- a/AxonIvyPortal/portal-selenium-test/customized_pom.xml +++ b/AxonIvyPortal/portal-selenium-test/customized_pom.xml @@ -20,7 +20,7 @@ com.axonivy.ivy.webtest web-tester - 10.0.0 + 11.3.0 test diff --git a/AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml b/AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml index 7a28757bc32..09bffcb6333 100644 --- a/AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml +++ b/AxonIvyPortal/portal-selenium-test/document_screenshot_pom.xml @@ -30,7 +30,7 @@ com.axonivy.ivy.webtest web-tester - 10.0.0 + 11.3.0 test diff --git a/AxonIvyPortal/portal-selenium-test/pom.xml b/AxonIvyPortal/portal-selenium-test/pom.xml index 478f051d08a..9b533775639 100644 --- a/AxonIvyPortal/portal-selenium-test/pom.xml +++ b/AxonIvyPortal/portal-selenium-test/pom.xml @@ -15,7 +15,7 @@ com.axonivy.ivy.webtest web-tester - 10.0.0 + 11.3.0 test diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/ComplexFilterHelper.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/ComplexFilterHelper.java index 8c26728eac8..176cfec0fd5 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/ComplexFilterHelper.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/ComplexFilterHelper.java @@ -15,6 +15,7 @@ import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebElementCondition; public class ComplexFilterHelper { protected final static Duration DEFAULT_TIMEOUT = Duration.ofSeconds(45); @@ -219,7 +220,7 @@ private static SelenideElement getValueOfCheckBox(String value) { .$$("li.ui-selectcheckboxmenu-item").filter(text(value)).first().$("div.ui-chkbox-box"); } - protected static Condition getClickableCondition() { + protected static WebElementCondition getClickableCondition() { return and("should be clickable", visible, exist); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/AbsencePage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/AbsencePage.java index 0db6b045aa4..97f325a8b2d 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/AbsencePage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/AbsencePage.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.stream.Collectors; -import org.apache.commons.collections4.CollectionUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -15,6 +14,7 @@ import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; @@ -68,14 +68,14 @@ public String getMyDisabledDeputy(int deputyRoleIndex) { } public String getIAMDeputyFor() { - List noteAuthorElements = $$("tbody[id*='substitution-table_data'] > tr > td"); - return noteAuthorElements.stream().map(w -> w.getText()).collect(Collectors.joining()); + ElementsCollection noteAuthorElements = $$("tbody[id*='substitution-table_data'] > tr > td"); + return noteAuthorElements.asFixedIterable().stream().map(w -> w.getText()).collect(Collectors.joining()); } public int indexOfDeputyRole(DeputyRoleType deputyRoleType) { String deputyRoleTypeSelector = ".substitute-table .substition-role-type"; - List elements = $$(deputyRoleTypeSelector); - if (CollectionUtils.isNotEmpty(elements)) { + ElementsCollection elements = $$(deputyRoleTypeSelector); + if (!elements.isEmpty()) { for (int index = 0; index < elements.size(); index++) { SelenideElement element = elements.get(index); String deputyRoleTypeValue = element.getAttribute("deputy-role-type"); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/CaseDetailsPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/CaseDetailsPage.java index 9adacb2c1f3..cec20f12a4e 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/CaseDetailsPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/CaseDetailsPage.java @@ -403,7 +403,7 @@ public String getLatestHistoryContent() { } public boolean isBusinessCaseInformationSectionDisplayed() { - List elements = $$("[id$='business-case-information']"); + ElementsCollection elements = $$("[id$='business-case-information']"); return !elements.isEmpty(); } @@ -653,7 +653,7 @@ public boolean isDownloadCompleted(String statusDialogId) { } public Integer getTaskRowIndex(String taskName) { - List taskNames = $$(".task-name-value"); + ElementsCollection taskNames = $$(".task-name-value"); int taskIndex = IntStream.range(0, taskNames.size()).filter(i -> taskNames.get(i).getText().equals(taskName)) .findFirst().getAsInt(); return taskIndex; @@ -677,7 +677,7 @@ public void clickRelatedTaskActionButton(String taskName) { } public int getTaskRowIndexFromDetailPage(String taskName) { - List taskNames = $$(".task-name-value"); + ElementsCollection taskNames = $$(".task-name-value"); int taskIndex = IntStream.range(0, taskNames.size()).filter(i -> taskNames.get(i).getText().equals(taskName)) .findFirst().getAsInt(); return taskIndex; @@ -761,14 +761,14 @@ public void selectDelegateResponsible(String responsibleName, boolean isRole) { $(By.cssSelector("input[id$='group-activator-select_input']")).click(); $(By.cssSelector("input[id$='group-activator-select_input']")).sendKeys(responsibleName); waitForElementDisplayed(By.cssSelector("span[id$='group-activator-select_panel']"), true); - List foundRoles = $$("span[id$='group-activator-select_panel'] .name-after-avatar"); + ElementsCollection foundRoles = $$("span[id$='group-activator-select_panel'] .name-after-avatar"); foundRoles.get(0).click(); } else { waitForElementDisplayed(By.cssSelector("input[id$='user-activator-select_input']"), true); $(By.cssSelector("input[id$='user-activator-select_input']")).click(); $(By.cssSelector("input[id$='user-activator-select_input']")).sendKeys(responsibleName); waitForElementDisplayed(By.cssSelector("span[id$='user-activator-select_panel']"), true); - List foundUsers = $$("span[id$='user-activator-select_panel'] .name-after-avatar"); + ElementsCollection foundUsers = $$("span[id$='user-activator-select_panel'] .name-after-avatar"); foundUsers.get(0).click(); } waitForElementClickableThenClick($(By.cssSelector("button[id$='proceed-task-delegate-command']"))); @@ -897,7 +897,7 @@ public boolean isRelatedCaseListColumnExist(String columnClass) { } public boolean isRelatedCaseListColumnNotExist(String columnClass) { - List columns = $$(".related-cases-container th." + columnClass); + ElementsCollection columns = $$(".related-cases-container th." + columnClass); return !columns.isEmpty() && !columns.get(0).isDisplayed(); } @@ -992,14 +992,13 @@ public TaskDetailsPage openTasksOfCasePage(String taskName) { } public boolean hasDoneTask() { - List doneTasks = $$(DONE_TASKS_SELECTOR); - return CollectionUtils.isNotEmpty(doneTasks); + ElementsCollection doneTasks = $$(DONE_TASKS_SELECTOR); + return !doneTasks.isEmpty(); } public List getCaseNoteAuthors() { - List noteAuthorElements = - $$("span.history-fullname").shouldBe(CollectionCondition.sizeGreaterThanOrEqual(0), DEFAULT_TIMEOUT); - return noteAuthorElements.stream().map(w -> w.getText()).collect(Collectors.toList()); + ElementsCollection noteAuthorElements = $$("span.history-fullname").shouldBe(CollectionCondition.sizeGreaterThanOrEqual(0), DEFAULT_TIMEOUT); + return noteAuthorElements.asFixedIterable().stream().map(w -> w.getText()).collect(Collectors.toList()); } public void clickBackButton() { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ChatPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ChatPage.java index d266508dda6..73c767afbc6 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ChatPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ChatPage.java @@ -15,7 +15,6 @@ import com.axonivy.portal.selenium.common.WaitHelper; import com.codeborne.selenide.Condition; import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; import ch.ivyteam.ivy.project.portal.test.Responsible; @@ -84,7 +83,7 @@ public int refreshAndCountGroupChat() { refresh(); getChat(); waitForElementDisplayed(By.id("chat-form:group-chat-container"), true); - List chatGroups = findElementById("chat-form:group-chat-container").findAll(".js-group-card-name"); + ElementsCollection chatGroups = findElementById("chat-form:group-chat-container").findAll(".js-group-card-name"); return chatGroups.size(); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardConfigurationPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardConfigurationPage.java index 7dd61c03998..3872980e27d 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardConfigurationPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardConfigurationPage.java @@ -9,11 +9,14 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Action; +import org.openqa.selenium.interactions.Actions; import com.axonivy.portal.selenium.common.FileHelper; import com.codeborne.selenide.Condition; import com.codeborne.selenide.DragAndDropOptions; import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; public class DashboardConfigurationPage extends TemplatePage { @@ -349,8 +352,14 @@ public void reorderPrivateDashboard(String fromDashboardName, String toDashboard } private void dragAndDropTo(SelenideElement toRow, SelenideElement fromRow) { - var targetCssSelector = String.format("[id$='%s']", toRow.getAttribute("id")); - fromRow.dragAndDropTo(targetCssSelector, DragAndDropOptions.usingActions()); + SelenideElement targetCssSelector = $("[id$='"+ toRow.getAttribute("id") + "']"); + Actions builder = new Actions(WebDriverRunner.getWebDriver()); + Action dragAndDrop = builder.clickAndHold(fromRow).pause(500) + .moveToElement(targetCssSelector, 50, 20).pause(500).release(targetCssSelector) + .pause(500) + .build(); + dragAndDrop.perform(); + } public void reorderPublicDashboard(String fromDashboardName, String toDashboardName) { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardNewsWidgetPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardNewsWidgetPage.java index ad434100d7b..12f29d99200 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardNewsWidgetPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/DashboardNewsWidgetPage.java @@ -9,6 +9,7 @@ import com.codeborne.selenide.Condition; import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebElementCondition; public class DashboardNewsWidgetPage extends TemplatePage { @@ -111,7 +112,7 @@ public void publishNews() { manageNewsDialogShouldBe(disappear); } - private SelenideElement manageNewsDialogShouldBe(Condition expectCondition) { + private SelenideElement manageNewsDialogShouldBe(WebElementCondition expectCondition) { return $("[id$=':manage-news-dialog']").shouldBe(expectCondition, DEFAULT_TIMEOUT); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestIFramePage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestIFramePage.java index e7c926d65a9..72b6ac6bedd 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestIFramePage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestIFramePage.java @@ -3,7 +3,6 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import java.util.List; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; @@ -13,7 +12,7 @@ import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.ElementsCollection; public class LeaveRequestIFramePage extends TaskTemplateIFramePage { @@ -46,8 +45,8 @@ public String clickSubmitAndGetValidationMsg() { } public String getValidationMsg() { - List messages = $$("span.ui-messages-error-summary"); - return StringUtils.join(messages.stream().map(WebElement::getText).collect(Collectors.toList()), ","); + ElementsCollection messages = $$("span.ui-messages-error-summary"); + return StringUtils.join(messages.asFixedIterable().stream().map(WebElement::getText).collect(Collectors.toList()), ","); } public void enterLeaveRequestInformation(String leaveType, String from, String to, String approver, diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestPage.java index 0f937187335..52d7d8eead2 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/LeaveRequestPage.java @@ -3,7 +3,6 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import java.util.List; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; @@ -13,7 +12,7 @@ import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.ElementsCollection; public class LeaveRequestPage extends TaskTemplateIFramePage { @@ -58,8 +57,8 @@ private void clickSubmitAndWaitValidationSummary(int numberOfErrors) { } public String getValidationMsg() { - List messages = $$("span.ui-messages-error-summary"); - return StringUtils.join(messages.stream().map(WebElement::getText).collect(Collectors.toList()), ","); + ElementsCollection messages = $$("span.ui-messages-error-summary"); + return StringUtils.join(messages.asFixedIterable().stream().map(WebElement::getText).collect(Collectors.toList()), ","); } public void enterLeaveRequestInformation(String leaveType, String from, String to, String approver, diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java index 977c1937081..aa73b4029ce 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java @@ -6,8 +6,6 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import java.util.List; - import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Keys; @@ -971,7 +969,7 @@ public void markAsRead(WebElement notificationsPanel, int expectedBadge) { } public int findNumberOfNotificationsItem(WebElement notificationsPanel) { - List item = $$(".ui-datascroller-item"); + ElementsCollection item = $$(".ui-datascroller-item"); return item.size(); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NoteHistoryPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NoteHistoryPage.java index 1de8b1da85b..ab1840ee09e 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NoteHistoryPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NoteHistoryPage.java @@ -10,7 +10,7 @@ import org.openqa.selenium.WebElement; import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.WebDriverRunner; public class NoteHistoryPage extends TemplatePage { @@ -60,9 +60,9 @@ public String getCaseId() { } public List getNoteAuthors() { - List noteAuthorElements = $$("td.note-history-fullname-column .name-after-avatar") + ElementsCollection noteAuthorElements = $$("td.note-history-fullname-column .name-after-avatar") .shouldBe(CollectionCondition.sizeGreaterThanOrEqual(0), DEFAULT_TIMEOUT); - return noteAuthorElements.stream().map(w -> w.getText()).collect(Collectors.toList()); + return noteAuthorElements.asFixedIterable().stream().map(w -> w.getText()).collect(Collectors.toList()); } public void clickOnCheckboxShowSystemNotes() { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessEditWidgetNewDashBoardPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessEditWidgetNewDashBoardPage.java index bb62e2f8b61..61f018e1247 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessEditWidgetNewDashBoardPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessEditWidgetNewDashBoardPage.java @@ -435,7 +435,7 @@ public void save() { public void dragAndDropProcess(int fromIndex, int toIndex) { SelenideElement processList = $("ul.ui-widget-content"); processList.shouldBe(Condition.appear, DEFAULT_TIMEOUT); - List findAll = processList.findAll("li.ui-orderlist-item"); + ElementsCollection findAll = processList.findAll("li.ui-orderlist-item"); if (findAll.size() > toIndex) { SelenideElement fromElement = findAll.get(fromIndex) .$(".process-start-list-item").shouldBe(clickable(), DEFAULT_TIMEOUT); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessWidgetPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessWidgetPage.java index 3d2ef4de049..2ad9b1bc935 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessWidgetPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ProcessWidgetPage.java @@ -5,9 +5,6 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import java.util.List; - -import org.apache.commons.collections4.CollectionUtils; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; @@ -15,6 +12,7 @@ import com.axonivy.portal.selenium.common.FileHelper; import com.axonivy.portal.selenium.common.WaitHelper; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; public class ProcessWidgetPage extends TemplatePage { @@ -207,8 +205,8 @@ public void selectViewMode(String viewMode) { waitForElementDisplayed(By.cssSelector("[id$='process-widget:process-view-mode:view-mode-selection']"), true); SelenideElement viewModeElement = findElementByCssSelector("[id$='process-widget:process-view-mode:view-mode-selection']"); - List webElements = viewModeElement.$$(By.cssSelector("span.ui-button-text.ui-c")); - if (CollectionUtils.isNotEmpty(webElements)) { + ElementsCollection webElements = viewModeElement.$$(By.cssSelector("span.ui-button-text.ui-c")); + if (!webElements.isEmpty()) { for (SelenideElement webElement : webElements) { if (webElement.getText().equalsIgnoreCase(viewMode)) { waitForElementClickableThenClick(webElement); @@ -236,7 +234,7 @@ public void enterSearchKeyword(String keyword) { public SelenideElement getStartImageProcess(String processName, SelenideElement processListElement) { SelenideElement startProcessItemElement = null; - List processItems = processListElement.$$(".js-process-start-list-item"); + ElementsCollection processItems = processListElement.$$(".js-process-start-list-item"); for (SelenideElement process : processItems) { SelenideElement processNameElement = process.$(".js-process-start-list-item-name"); if (processNameElement.isDisplayed() && processName.equalsIgnoreCase(processNameElement.getText())) { @@ -256,7 +254,7 @@ public SelenideElement getProcess(String processName) { } public boolean isImageModeActivated() { - List findElements = $$(By.cssSelector("[id$=':image-process-container']")); + ElementsCollection findElements = $$(By.cssSelector("[id$=':image-process-container']")); return !findElements.isEmpty(); } @@ -270,13 +268,13 @@ public boolean isNoProcessFound() { public boolean isProcessGroupDisplay(String processGroupCharacter) { if (isImageModeActivated()) { - List webElements = $$(".js-grid-process-index-group"); - return webElements.stream().anyMatch(processItem -> processItem.isDisplayed() + ElementsCollection webElements = $$(".js-grid-process-index-group"); + return webElements.asFixedIterable().stream().anyMatch(processItem -> processItem.isDisplayed() && processItem.getAttribute("class").endsWith(processGroupCharacter)); } - List indexGroup = + ElementsCollection indexGroup = $$(By.xpath("//legend[@class='ui-fieldset-legend ui-corner-all ui-state-default']")); - return indexGroup.stream().anyMatch(item -> processGroupCharacter.equals(item.getText())); + return indexGroup.asFixedIterable().stream().anyMatch(item -> processGroupCharacter.equals(item.getText())); } public String getCurrentViewMode() { @@ -374,7 +372,7 @@ public void clickProcessMoreActionMenu(String processName) { public SelenideElement getProcessItem(String processName) { SelenideElement processItemElement = null; - List processItems = $$(".js-process-start-list-item"); + ElementsCollection processItems = $$(".js-process-start-list-item"); for (SelenideElement process : processItems) { processItemElement = process.$(".js-process-start-list-item-name"); if (processItemElement.getText().equalsIgnoreCase(processName)) { @@ -408,7 +406,7 @@ public void deleteGridProcess(String processName) { public SelenideElement getProcessItemForm(String processName) { SelenideElement processItemElement = null; - List processItems = $$(".js-process-start-list-item form"); + ElementsCollection processItems = $$(".js-process-start-list-item form"); for (SelenideElement process : processItems) { processItemElement = process.$(".js-process-start-list-item-name"); if (processItemElement.getText().equalsIgnoreCase(processName)) { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ReorderDashboardPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ReorderDashboardPage.java index cf3328c8774..18ceebb1e07 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ReorderDashboardPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/ReorderDashboardPage.java @@ -4,12 +4,13 @@ import static com.codeborne.selenide.Condition.disappear; import static com.codeborne.selenide.Selenide.$; -import com.codeborne.selenide.DragAndDropOptions; +import org.openqa.selenium.interactions.Action; +import org.openqa.selenium.interactions.Actions; + import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; public class ReorderDashboardPage extends TemplatePage { - private static final String ID_SELECTOR_PATTERN = "[id$='%s']"; - @Override protected String getLoadedLocator() { return "i.dashboard-icon-drag-drop"; @@ -28,8 +29,14 @@ public void reorderPrivateDashboard(String fromDashboardName, String toDashboard } private void dragAndDropTo(SelenideElement toRow, SelenideElement fromRow) { - var targetCssSelector = String.format(ID_SELECTOR_PATTERN, toRow.getAttribute("id")); - fromRow.dragAndDropTo(targetCssSelector, DragAndDropOptions.usingActions()); + SelenideElement targetCssSelector = $("[id$='" + toRow.getAttribute("id") + "']"); + Actions builder = new Actions(WebDriverRunner.getWebDriver()); + Action dragAndDrop = builder.clickAndHold(fromRow).pause(500) + .moveToElement(targetCssSelector, 50, 20).pause(500).release(targetCssSelector) + .pause(500) + .build(); + dragAndDrop.perform(); + } public void reorderPublicDashboard(String fromDashboardName, String toDashboardName) { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/RoleManagementPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/RoleManagementPage.java index 8419510fdd5..ed2c3bc2d02 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/RoleManagementPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/RoleManagementPage.java @@ -146,7 +146,7 @@ public SelenideElement findActionForRoleByName(String roleName, String actionId) .shouldBe(Condition.appear, DEFAULT_TIMEOUT); } - private List getRolesOnTheTreeTable() { + private ElementsCollection getRolesOnTheTreeTable() { return getRoleTreeTable().$$(By.cssSelector("tbody tr.role")); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/SearchResultPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/SearchResultPage.java index 7918279aef7..ecba3dca487 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/SearchResultPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/SearchResultPage.java @@ -8,6 +8,7 @@ import org.openqa.selenium.By; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; public class SearchResultPage extends TemplatePage { @@ -63,7 +64,7 @@ public String getCaseResult(int index) { public int countCase() { waitCaseWidgetLoaded(); - List caseItems = $$("li[class='ui-datascroller-item']"); + ElementsCollection caseItems = $$("li[class='ui-datascroller-item']"); return caseItems.size(); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java index 42d1fa683cf..30860893e9d 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java @@ -299,15 +299,15 @@ public String getTaskUuid() { public List getTaskNoteHasAuthors() { ScreenshotUtils.resizeBrowser(new Dimension(2560, 1600)); $("th.task-document-author").shouldBe(appear); - List noteAuthorElements = + ElementsCollection noteAuthorElements = $$("td.task-document-author .name-after-avatar").shouldBe(CollectionCondition.sizeGreaterThanOrEqual(1)); - return noteAuthorElements.stream().map(w -> w.getText()).collect(Collectors.toList()); + return noteAuthorElements.asFixedIterable().stream().map(w -> w.getText()).collect(Collectors.toList()); } public List getTaskNoteAuthors() { - List noteAuthorElements = $$("td.task-document-author .name-after-avatar") + ElementsCollection noteAuthorElements = $$("td.task-document-author .name-after-avatar") .shouldBe(CollectionCondition.sizeGreaterThanOrEqual(0), DEFAULT_TIMEOUT); - return noteAuthorElements.stream().map(w -> w.getText()).collect(Collectors.toList()); + return noteAuthorElements.asFixedIterable().stream().map(w -> w.getText()).collect(Collectors.toList()); } public void clickBackButton() { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskIFrameTemplatePage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskIFrameTemplatePage.java index ece5b31220d..208d9023cbb 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskIFrameTemplatePage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskIFrameTemplatePage.java @@ -5,7 +5,6 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import java.util.List; import java.util.stream.IntStream; import org.openqa.selenium.By; @@ -16,6 +15,7 @@ import com.axonivy.portal.selenium.common.WaitHelper; import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverRunner; @@ -173,7 +173,7 @@ public TaskDetailsPage openRelatedTaskInList(String taskName) { } public Integer getTaskRowIndex(String taskName) { - List taskNames = $$(".task-name-value"); + ElementsCollection taskNames = $$(".task-name-value"); int taskIndex = IntStream.range(0, taskNames.size()).filter(i -> taskNames.get(i).getText().equals(taskName)) .findFirst().getAsInt(); return taskIndex; diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskTemplatePage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskTemplatePage.java index c1468a1e32b..b5b1443f124 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskTemplatePage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskTemplatePage.java @@ -5,7 +5,6 @@ import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -import java.util.List; import java.util.stream.IntStream; import org.openqa.selenium.By; @@ -15,6 +14,7 @@ import com.axonivy.portal.selenium.common.NavigationHelper; import com.axonivy.portal.selenium.common.WaitHelper; import com.codeborne.selenide.CollectionCondition; +import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; public class TaskTemplatePage extends TemplatePage { @@ -169,7 +169,7 @@ public TaskDetailsPage openRelatedTaskInList(String taskName) { } public Integer getTaskRowIndex(String taskName) { - List taskNames = $$(".task-name-value"); + ElementsCollection taskNames = $$(".task-name-value"); int taskIndex = IntStream.range(0, taskNames.size()).filter(i -> taskNames.get(i).getText().equals(taskName)) .findFirst().getAsInt(); return taskIndex; diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskWidgetPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskWidgetPage.java index ce14cbdf225..7bd71fcecd0 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskWidgetPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskWidgetPage.java @@ -322,7 +322,7 @@ public void clickOnTaskStatesAndApply(List states) { "table[id$=':filter-input-form:state-selection'] div.ui-chkbox-box span.ui-chkbox-icon.ui-icon-blank")) .size() == labelList.size(); }); - List checkBoxList = getStateFilterPanel() + ElementsCollection checkBoxList = getStateFilterPanel() .$$(By.cssSelector("table[id$=':filter-input-form:state-selection'] div.ui-chkbox-box.ui-state-default")); statesSelectedIndex.forEach(index -> { waitForElementClickableThenClick(checkBoxList.get(index)); @@ -540,7 +540,7 @@ public void confimDestruction() { public boolean isTaskDelegateOptionDisable(String taskName) { int index = 1; - List taskElements = $$("span[id$=':task-item:task-name-component:task-name']"); + ElementsCollection taskElements = $$("span[id$=':task-item:task-name-component:task-name']"); for (int i = 0; i < taskElements.size(); i++) { if (taskElements.get(i).getText().equals(taskName)) { index = i; @@ -590,7 +590,7 @@ public String getFilterValue(String filterId) { } public String getResponsibleOfTaskAt(int index) { - List responsibles = $$(".responsible-cell .name-after-avatar"); + ElementsCollection responsibles = $$(".responsible-cell .name-after-avatar"); return responsibles.get(index).getText(); } @@ -637,7 +637,7 @@ public boolean isTaskStateOpen(int index) { } public boolean isCategoryColumnDisplayed() { - List taskCategoryCells = $$("span[id$=':task-category-cell']"); + ElementsCollection taskCategoryCells = $$("span[id$=':task-category-cell']"); for (SelenideElement categoryCell : taskCategoryCells) { if (categoryCell.isDisplayed()) { return true; @@ -694,7 +694,7 @@ public void selectDelegateResponsible(String responsibleName, boolean isRole) { responsibleElement.click(); responsibleElement.sendKeys(responsibleName); waitForElementDisplayed(By.cssSelector("span[id$='group-activator-select_panel']"), true); - List foundRoles = $$("span[id$='group-activator-select_panel'] .gravatar"); + ElementsCollection foundRoles = $$("span[id$='group-activator-select_panel'] .gravatar"); waitForElementClickableThenClick(foundRoles.get(0)); } else { waitForElementDisplayed(By.cssSelector("input[id$='user-activator-select_input']"), true); @@ -702,7 +702,7 @@ public void selectDelegateResponsible(String responsibleName, boolean isRole) { responsibleElement.click(); responsibleElement.sendKeys(responsibleName); waitForElementDisplayed(By.cssSelector("span[id$='user-activator-select_panel']"), true); - List foundUsers = $$("span[id$='user-activator-select_panel'] .name-after-avatar"); + ElementsCollection foundUsers = $$("span[id$='user-activator-select_panel'] .name-after-avatar"); waitForElementClickableThenClick(foundUsers.get(0)); } waitForElementClickableThenClick(By.cssSelector("button[id$='proceed-task-delegate-command']")); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TemplatePage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TemplatePage.java index 74f2da36859..4038d8afe67 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TemplatePage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TemplatePage.java @@ -34,6 +34,7 @@ import com.codeborne.selenide.SelenideElement; import com.codeborne.selenide.WebDriverConditions; import com.codeborne.selenide.WebDriverRunner; +import com.codeborne.selenide.WebElementCondition; import com.codeborne.selenide.conditions.Not; public abstract class TemplatePage extends AbstractPage { @@ -60,11 +61,11 @@ public void assertPageTitle(String titleExpect) { webdriver().shouldHave(WebDriverConditions.title(titleExpect)); } - protected Condition getClickableCondition() { + protected WebElementCondition getClickableCondition() { return and("should be clickable", visible, exist); } - protected Condition clickable() { + protected WebElementCondition clickable() { return and("should be clickable", visible, enabled); } @@ -182,7 +183,7 @@ public void waitForElementPresent(By element, boolean expected) { if (expected) { $(element).shouldBe(exist, DEFAULT_TIMEOUT); } else { - $(element).shouldBe(Not.exist, DEFAULT_TIMEOUT); + $(element).shouldNotBe(exist, DEFAULT_TIMEOUT); } } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TopMenuTaskWidgetPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TopMenuTaskWidgetPage.java index a7938f9ab88..df3ad0336fe 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TopMenuTaskWidgetPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TopMenuTaskWidgetPage.java @@ -253,7 +253,7 @@ public void selectDelegateResponsible(String responsibleName, boolean isRole) { responsibleElement.click(); responsibleElement.sendKeys(responsibleName); waitForElementDisplayed(By.cssSelector("span[id$='group-activator-select_panel']"), true); - List foundRoles = $$("span[id$='group-activator-select_panel'] .gravatar"); + ElementsCollection foundRoles = $$("span[id$='group-activator-select_panel'] .gravatar"); waitForElementClickableThenClick(foundRoles.get(0)); } else { waitForElementDisplayed(By.cssSelector("input[id$='user-activator-select_input']"), true); @@ -261,7 +261,7 @@ public void selectDelegateResponsible(String responsibleName, boolean isRole) { responsibleElement.click(); responsibleElement.sendKeys(responsibleName); waitForElementDisplayed(By.cssSelector("span[id$='user-activator-select_panel']"), true); - List foundUsers = $$("span[id$='user-activator-select_panel'] .name-after-avatar"); + ElementsCollection foundUsers = $$("span[id$='user-activator-select_panel'] .name-after-avatar"); waitForElementClickableThenClick(foundUsers.get(0)); } waitForElementClickableThenClick(By.cssSelector("button[id$='proceed-task-delegate-command']")); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/WelcomeEditWidgetNewDashboardPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/WelcomeEditWidgetNewDashboardPage.java index 83752848f17..e9264f20900 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/WelcomeEditWidgetNewDashboardPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/WelcomeEditWidgetNewDashboardPage.java @@ -34,9 +34,10 @@ public void inputWelcomeTexts(List welcomeTexts) { ElementsCollection welcomeTextInputs = configDialog.findAll(".js-welcome-text-input"); welcomeTextInputs.asDynamicIterable().forEach(elem -> { elem.clear(); - elem.sendKeys(welcomeTexts.stream().filter(text -> welcomeTexts.indexOf(text) == welcomeTextInputs.indexOf(elem)) - .findFirst().orElse("")); }); + for (int i = 0; i < welcomeTexts.size(); i++) { + $("input[id$='welcome-text-list:" + i + ":welcome-text-input']").sendKeys(welcomeTexts.get(i)); + } } public void selectTextSize(String value) { diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardRestoreConfigurationTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardRestoreConfigurationTest.java index 9d96eb6cc86..f1306a51c60 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardRestoreConfigurationTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardRestoreConfigurationTest.java @@ -16,6 +16,7 @@ import com.axonivy.portal.selenium.page.NewDashboardPage; import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; +import com.codeborne.selenide.WebElementsCondition; import ch.ivy.addon.portalkit.enums.PortalVariable; @@ -84,7 +85,7 @@ public void testCannotRestoreDashboardWhenTemplateNotFound() { restoreButton.shouldHave(Condition.cssClass("ui-state-disabled")); } - private void verifyEditingDashboardContent(String dashboardName, CollectionCondition collectionCondition) { + private void verifyEditingDashboardContent(String dashboardName, WebElementsCondition collectionCondition) { NewDashboardDetailsEditPage newDashboardDetailsEditPage = new NewDashboardDetailsEditPage(); newDashboardDetailsEditPage.getTitleByIndex(0).shouldBe(Condition.exactText(dashboardName)); newDashboardDetailsEditPage.getWidgets().shouldBe(collectionCondition);