Skip to content

Commit

Permalink
IVYPORTAL-17542-Use-latest-web-tester-to-run-all-tests (#1109)
Browse files Browse the repository at this point in the history
- update to ivy web-tester 11.3.0
- update proper api usage
  • Loading branch information
tphvu-axonivy authored Dec 3, 2024
1 parent 2c525b0 commit e45b686
Show file tree
Hide file tree
Showing 26 changed files with 96 additions and 82 deletions.
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal-selenium-test/customized_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.axonivy.ivy.webtest</groupId>
<artifactId>web-tester</artifactId>
<version>10.0.0</version>
<version>11.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.axonivy.ivy.webtest</groupId>
<artifactId>web-tester</artifactId>
<version>10.0.0</version>
<version>11.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion AxonIvyPortal/portal-selenium-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.axonivy.ivy.webtest</groupId>
<artifactId>web-tester</artifactId>
<version>10.0.0</version>
<version>11.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
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;
import org.openqa.selenium.support.ui.WebDriverWait;

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;

Expand Down Expand Up @@ -68,14 +68,14 @@ public String getMyDisabledDeputy(int deputyRoleIndex) {
}

public String getIAMDeputyFor() {
List<SelenideElement> 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<SelenideElement> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public String getLatestHistoryContent() {
}

public boolean isBusinessCaseInformationSectionDisplayed() {
List<SelenideElement> elements = $$("[id$='business-case-information']");
ElementsCollection elements = $$("[id$='business-case-information']");
return !elements.isEmpty();
}

Expand Down Expand Up @@ -653,7 +653,7 @@ public boolean isDownloadCompleted(String statusDialogId) {
}

public Integer getTaskRowIndex(String taskName) {
List<SelenideElement> 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;
Expand All @@ -677,7 +677,7 @@ public void clickRelatedTaskActionButton(String taskName) {
}

public int getTaskRowIndexFromDetailPage(String taskName) {
List<SelenideElement> 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;
Expand Down Expand Up @@ -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<SelenideElement> 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<SelenideElement> 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']")));
Expand Down Expand Up @@ -897,7 +897,7 @@ public boolean isRelatedCaseListColumnExist(String columnClass) {
}

public boolean isRelatedCaseListColumnNotExist(String columnClass) {
List<SelenideElement> columns = $$(".related-cases-container th." + columnClass);
ElementsCollection columns = $$(".related-cases-container th." + columnClass);
return !columns.isEmpty() && !columns.get(0).isDisplayed();
}

Expand Down Expand Up @@ -992,14 +992,13 @@ public TaskDetailsPage openTasksOfCasePage(String taskName) {
}

public boolean hasDoneTask() {
List<SelenideElement> doneTasks = $$(DONE_TASKS_SELECTOR);
return CollectionUtils.isNotEmpty(doneTasks);
ElementsCollection doneTasks = $$(DONE_TASKS_SELECTOR);
return !doneTasks.isEmpty();
}

public List<String> getCaseNoteAuthors() {
List<SelenideElement> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -84,7 +83,7 @@ public int refreshAndCountGroupChat() {
refresh();
getChat();
waitForElementDisplayed(By.id("chat-form:group-chat-container"), true);
List<SelenideElement> 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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -46,8 +45,8 @@ public String clickSubmitAndGetValidationMsg() {
}

public String getValidationMsg() {
List<SelenideElement> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -58,8 +57,8 @@ private void clickSubmitAndWaitValidationSummary(int numberOfErrors) {
}

public String getValidationMsg() {
List<SelenideElement> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -971,7 +969,7 @@ public void markAsRead(WebElement notificationsPanel, int expectedBadge) {
}

public int findNumberOfNotificationsItem(WebElement notificationsPanel) {
List<SelenideElement> item = $$(".ui-datascroller-item");
ElementsCollection item = $$(".ui-datascroller-item");
return item.size();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -60,9 +60,9 @@ public String getCaseId() {
}

public List<String> getNoteAuthors() {
List<SelenideElement> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SelenideElement> 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);
Expand Down
Loading

0 comments on commit e45b686

Please sign in to comment.