From 5f15fd39b9150161c0487c54f401a0ad912176e7 Mon Sep 17 00:00:00 2001 From: Thai Phan <117443490+pvthai-axonivy@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:25:34 +0700 Subject: [PATCH] IVYPORTAL-18153 Fix GUI tests (#1320) (#1350) * IVYPORTAL-18153 Fix GUI tests * IVYPORTAL-18153 Fix GUI tests - testDisplayDefaultGrowlAfterFinishTaskWithoutIFrame * IVYPORTAL-18153 Fix GUI tests - BackNavigationTest#testFinishTaskFromCaseDetailAndGoBack, BackNavigationTest#testNavigateAfterFinishedTaskToCaseDetails * IVYPORTAL-18153 Fix GUI tests - Try out to fix tests * IVYPORTAL-18153 Fix GUI tests - Try out to fix tests * IVYPORTAL-18153 Fix GUI tests - Try out to fix tests * IVYPORTAL-18153 Fix GUI tests - Try out to fix tests * IVYPORTAL-18153 Fix GUI tests - Try out to fix tests (cherry picked from commit cebde2a5d0af17b3cd1d91cefe6307250fcc49a5) Co-authored-by: Tung Le <76459536+lttung-axonivy@users.noreply.github.com> --- .../selenium/page/TaskIFrameTemplatePage.java | 21 ++++++++++++------- .../portal/selenium/page/TemplatePage.java | 8 ++++++- .../selenium/test/BackNavigationTest.java | 4 ++-- .../DashboardTaskWidgetFilterTest.java | 2 +- 4 files changed, 23 insertions(+), 12 deletions(-) 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 208d9023cbb..739567137f7 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 @@ -216,14 +216,19 @@ public void startSideStep() { } public void inputValue(String employee, String from, String to, String representation) { - $(By.id("leave-request:fullname")).shouldBe(Condition.appear).shouldBe(Condition.editable).sendKeys(employee); - $(By.id("leave-request:substitute")).sendKeys(representation); - $(By.id("leave-request:from_input")).sendKeys(from); - $(By.id("leave-request:to_input")).sendKeys(to); - } - - public void inputField(String cssSelector, String value) { - $(cssSelector).shouldBe(Condition.appear).shouldBe(Condition.editable).sendKeys(value); + SelenideElement fullNameElement = + $(By.id("leave-request:fullname")).shouldBe(Condition.appear).shouldBe(Condition.editable); + fullNameElement.click(); + fullNameElement.sendKeys(employee); + SelenideElement representationElement = $(By.id("leave-request:substitute")); + representationElement.click(); + representationElement.sendKeys(representation); + SelenideElement fromElement = $(By.id("leave-request:from_input")); + fromElement.click(); + fromElement.sendKeys(from); + SelenideElement toElement = $(By.id("leave-request:to_input")); + toElement.click(); + toElement.sendKeys(to); } public NewDashboardPage clickSubmitButton() { 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 952b993f09e..85b6c840b75 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 @@ -35,7 +35,6 @@ 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 { private static final int IFRAME_SCREENSHOT_FILE_SIZE_AT_MINIMUM = 10000; @@ -541,4 +540,11 @@ public QRCodePage openQRCode() { $("[id='mobile-app-item']").shouldBe(appear, DEFAULT_TIMEOUT).click(); return new QRCodePage(); } + + public void sendKeys(String cssSelector, String value) { + SelenideElement element = $(cssSelector).shouldBe(Condition.appear).shouldBe(Condition.editable); + element.click(); + element.clear(); + element.sendKeys(value); + } } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/BackNavigationTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/BackNavigationTest.java index c651ccb316f..f29f2313f3a 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/BackNavigationTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/BackNavigationTest.java @@ -135,9 +135,9 @@ public void testNavigateAfterFinishedTaskToCaseDetails() { taskDetailsPage = caseDetailsPage.openTasksOfCasePage(PAYMENT_TASK_NAME); TaskIFrameTemplatePage taskTemplatePage = taskDetailsPage.clickStartTask(); - taskTemplatePage.inputField("[id$='payment-request:fullname']", "Demo"); + taskTemplatePage.sendKeys("[id$='payment-request:fullname']", "Demo"); String today = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DateTimePattern.DATE_TIME_PATTERN)); - taskTemplatePage.inputField("[id$='payment-request:from_input']", today); + taskTemplatePage.sendKeys("[id$='payment-request:from_input']", today); taskTemplatePage.clickOnSubmitButton(); caseDetailsPage = new CaseDetailsPage(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardTaskWidgetFilterTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardTaskWidgetFilterTest.java index 538c14dcddc..b522f4b3a0c 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardTaskWidgetFilterTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/dashboard/DashboardTaskWidgetFilterTest.java @@ -192,7 +192,7 @@ public void testFilterDateOnCustomFields() { taskWidget = newDashboardPage.selectTaskWidget(YOUR_TASK_WIDGET); taskWidget.openFilterWidget(); taskWidget.addFilter("Shipment date", FilterOperator.BETWEEN); - taskWidget.inputValueOnLatestFilter(FilterValueType.DATE_BETWEEN, "01/01/2024","12/12/2024"); + taskWidget.inputValueOnLatestFilter(FilterValueType.DATE_BETWEEN, "01/01/2024", "12/12/2124"); taskWidget.clickOnWidgetFilterHeader(); taskWidget.applyFilter(); taskWidget.countAllTasks().shouldHave(CollectionCondition.size(2));