Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 3fc22270 authored by Mihai BOZ's avatar Mihai BOZ
Browse files

Pull request #29: EDELIVERY-11836 Progress on the automation of the DomiSMP UI tests Part 3

Merge in EDELIVERY/smp from EDELIVERY-11836-Progress-on-the-automation-of-the-DomiSMP-UI-tests-Part-3 to development

* commit '08bf3f92':
  fix comments
  added method to generate random value from enum, resolved other PR comments
  Added TrustorePage and TrustorePGtests - work in progress Added FileUtils class.
  Added EditDomainPage, automated DOM-03 System admin is able to Invite/Remove users from domains
  Added MembersTab for DomainPage, changed Pagination and Smallgrid to take into consideration the parent.
  Added ResourceTab, SMLIntegration tab, removed unused code, change the locators for pagination,
parents 1b529ed5 08bf3f92
No related branches found
No related tags found
No related merge requests found
Pipeline #83606 passed with warnings
Showing
with 418 additions and 205 deletions
......@@ -30,9 +30,6 @@ public class DomiSMPPage extends DComponent {
private WebElement rightMenuBtn;
@FindBy(id = "logout_id")
private WebElement logoutMenuBtn;
@FindBy(className = "smp-expired-password-dialog")
private WebElement expiredPasswordDialog;
@FindBy(css = "#okbuttondialog_id ")
private WebElement dialogOKbutton;
......@@ -75,30 +72,13 @@ public class DomiSMPPage extends DComponent {
}
public boolean isExpiredDialoginbuttonEnabled() {
return dialogOKbutton.isEnabled();
}
public boolean isExpiredPopupEnabled() {
try {
return dialogOKbutton.isDisplayed();
return dialogOKbutton.isEnabled();
} catch (Exception e) {
LOG.info("Expiration poup not found", e);
return false;
}
}
public void closeExpirationPopupIfEnabled() {
try {
if (isExpiredPopupEnabled()) {
LOG.info("Expired password dialog is present.");
getSidebar().getExpiredDialoginbutton().click();
}
} catch (Exception e) {
LOG.error("Could not close Expiration popup", e);
}
}
public void waitForPageToLoaded() {
wait.defaultWait.until(ExpectedConditions.visibilityOf(getBreadcrump().BreadcrumpItems.get(0)));
}
......
......@@ -7,22 +7,26 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class PageWithGrid extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(PageWithGrid.class);
/**
* Generic page used for pages which have small grid in the right of the page. This element gives access to action buttons and elements of the page.
*/
@FindBy(css = "mat-form-field input")
public WebElement FilterInput;
public WebElement filterInput;
@FindBy(css = "data-panel >div >div> mat-toolbar button:first-of-type")
public WebElement AddBtn;
@FindBy(css = "data-panel >div >div> mat-toolbar button:last-of-type")
public WebElement DeleteBtn;
@FindBy(css = "data-panel > div [class=\"smp-column-data\"]")
public WebElement SidePanel;
public WebElement addBtn;
@FindBy(css = "data-panel")
public WebElement dataPanel;
@FindBy(css = "[role = \"tab\"]")
private List<WebElement> tabList;
public PageWithGrid(WebDriver driver) {
super(driver);
......@@ -30,20 +34,25 @@ public class PageWithGrid extends DomiSMPPage {
}
public GridPagination getPagination() {
return new GridPagination(driver);
return new GridPagination(driver, dataPanel);
}
public SmallGrid getGrid() {
return new SmallGrid(driver);
public SmallGrid getDataPanelGrid() {
return new SmallGrid(driver, dataPanel);
}
public void filter(String filterValue) {
try {
weToDInput(FilterInput).fill(filterValue);
} catch (Exception e) {
throw new RuntimeException(e);
public void goToTab(String tabName) {
for (WebElement element : tabList) {
if (element.getText().contains(tabName)) {
element.click();
wait.forAttributeToContain(element, "aria-selected", "true");
LOG.debug("Domain tab {} is opened", tabName);
}
}
}
public String getAlertMessageAndClose() {
return getAlertArea().getAlertMessage();
}
}
......@@ -18,6 +18,10 @@ public class AlertComponent extends DComponent {
@FindBy(id = "alertmessage_id")
public WebElement alertToaster;
@FindBy(css = "[class = \"closebtn\"]")
public WebElement closeBtn;
public AlertComponent(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getTIMEOUT()), this);
......@@ -28,11 +32,11 @@ public class AlertComponent extends DComponent {
wait.forElementToBeVisible(alertToaster, true);
String alertMesageText = alertToaster.getText().replace("×", "").replaceAll("\n", "");
LOG.debug("Displayed message : {}.", alertToaster.getText());
closeBtn.click();
return alertMesageText;
} catch (Exception e) {
LOG.debug("No messages displayed.");
return null;
LOG.error("No messages displayed.");
return "No alert message found";
}
}
......
......@@ -29,7 +29,7 @@ public class ConfirmationDialog extends DComponent {
LOG.info("dialog .. confirm");
wait.forElementToBeClickable(yesBtn);
yesBtn.click();
wait.forElementToBeClickable(yesBtn);
wait.forElementToBeGone(yesBtn);
}
public void cancel() {
......
package ddsl.dcomponents.Grid;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -13,34 +13,25 @@ import java.util.regex.Pattern;
public class GridPagination extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(GridPagination.class);
protected static final By currentElementsLblLocator = By.cssSelector("div.mat-mdc-paginator-range-label");
protected static final By nextPageBtnLocator = By.cssSelector("[aria-label= \"Next page\"]");
private final WebElement parentElement;
@FindBy(css = "#extension-paginator > div > div > div > div")
public WebElement currentElementsLbl;
@FindBy(css = "#extension-paginator > div > div > div [aria-label = \"First page\"]")
public WebElement firstPageBtn;
@FindBy(css = "#extension-paginator > div > div > div [aria-label = \"Next page\"]")
public WebElement previousPageBtn;
@FindBy(css = "#extension-paginator > div > div > div [aria-label = \"Next page\"]")
public WebElement nextPageBtn;
@FindBy(css = "#extension-paginator > div > div > div [aria-label = \"Last page\"]")
public WebElement lastPageBtn;
public GridPagination(WebDriver driver) {
public GridPagination(WebDriver driver, WebElement parentElement) {
super(driver);
PageFactory.initElements(driver, this);
this.parentElement = parentElement;
}
public Integer getTotalPageNumber() {
String val = currentElementsLbl.getText();
String val = parentElement.findElement(currentElementsLblLocator).getText();
Integer numofElementsPerPage = 5;
Pattern pattern = Pattern.compile("of (\\d+)");
Matcher matcher = pattern.matcher(val);
if (matcher.find()) {
Integer totalRecord = Integer.parseInt(matcher.group(1));
return (totalRecord % 5 == 0) ? (totalRecord / 5) : ((totalRecord / 5) + 1);
return (totalRecord % numofElementsPerPage == 0) ? (totalRecord / numofElementsPerPage) : ((totalRecord / numofElementsPerPage) + 1);
}
return null;
}
......@@ -48,8 +39,8 @@ public class GridPagination extends DComponent {
public void goToNextPage() {
try {
if (weToDButton(nextPageBtn).isPresent()) {
weToDButton(nextPageBtn).click();
if (weToDButton(parentElement.findElement(nextPageBtnLocator)).isPresent()) {
weToDButton(parentElement.findElement(nextPageBtnLocator)).click();
LOG.error("Click on Grid Next Page button");
} else {
......@@ -61,13 +52,4 @@ public class GridPagination extends DComponent {
}
}
public void goToPreviousPage() throws Exception {
if (weToDButton(previousPageBtn).isEnabled()) {
weToDButton(previousPageBtn).click();
} else {
LOG.error("Previous page button is not available.");
}
}
}
......@@ -4,9 +4,7 @@ import ddsl.dcomponents.DComponent;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -14,29 +12,28 @@ import java.util.List;
public class SmallGrid extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(SmallGrid.class);
protected static final By gridHeadersLocator = By.cssSelector("table thead th");
protected static final By gridRowsLocator = By.cssSelector("table tbody tr");
private final WebElement parentElement;
@FindBy(css = "data-panel table thead th")
protected List<WebElement> gridHeaders;
@FindBy(css = "data-panel table tbody tr")
protected List<WebElement> gridRows;
public SmallGrid(WebDriver driver) {
public SmallGrid(WebDriver driver, WebElement parentElement) {
super(driver);
PageFactory.initElements(driver, this);
this.parentElement = parentElement;
}
public GridPagination getGridPagination() {
return new GridPagination(driver);
return new GridPagination(driver, parentElement);
}
public List<WebElement> gerGridHeaders() {
return wait.defaultWait.until(ExpectedConditions.visibilityOfAllElements(gridHeaders));
public List<WebElement> getGridHeaders() {
return parentElement.findElements(gridHeadersLocator);
}
public List<WebElement> getRows() {
wait.forXMillis(50);
return wait.defaultWait.until(ExpectedConditions.visibilityOfAllElements(gridRows));
return parentElement.findElements(gridRowsLocator);
}
public List<WebElement> getCells(WebElement row) {
......@@ -45,8 +42,9 @@ public class SmallGrid extends DComponent {
public WebElement searchValueInColumn(String columnName, String value) {
wait.forXMillis(100);
Integer numOfPages = getGridPagination().getTotalPageNumber();
List<WebElement> rowHeaders = gerGridHeaders();
List<WebElement> rowHeaders = getGridHeaders();
int columnIndex = -1;
for (int i = 0; i < rowHeaders.size(); i++) {
if (rowHeaders.get(i).getText().equals(columnName)) {
......
......@@ -7,16 +7,16 @@ import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.ProfilePage.SuccesfullPasswordChangedPopup;
import pages.profilePage.SuccesfullPasswordChangedPopup;
import java.util.ArrayList;
import java.util.List;
public class SetChangePasswordDialog extends DComponent {
/**
* Component object for dialog of changing password.
* Page object for the Set/change password dialog. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(SetChangePasswordDialog.class);
@FindBy(css = ".smp-field-error")
List<WebElement> fieldsError;
......@@ -28,8 +28,6 @@ public class SetChangePasswordDialog extends DComponent {
private WebElement confirmationPasswordInput;
@FindBy(id = "changeCurrentUserPasswordButton")
private WebElement setPasswordBtn;
@FindBy(id = "closeDialogButton")
private WebElement closeBtn;
public SetChangePasswordDialog(WebDriver driver) {
......
......@@ -2,20 +2,20 @@ package ddsl.dcomponents;
import ddsl.DomiSMPPage;
import ddsl.enums.Pages;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.DomainsPage.DomainsPage;
import pages.ProfilePage.ProfilePage;
import pages.PropertiesPage.PropertiesPage;
import pages.TruststorePage;
import pages.UsersPage;
import pages.editDomainsPage.EditDomainsPage;
import pages.profilePage.ProfilePage;
import pages.propertiesPage.PropertiesPage;
import java.util.Objects;
......@@ -103,29 +103,16 @@ public class SideNavigationComponent extends DomiSMPPage {
return null;
}
public <T> T navigateTo2(Pages page) {
wait.defaultWait.until(ExpectedConditions.visibilityOf(sideBar));
if (page == Pages.SYSTEM_SETTINGS_DOMAINS) {
openSubmenu(systemSettingsExpand, domainsLnk);
return (T) new DomainsPage(driver);
}
return null;
}
public DomiSMPPage navigateTo(Pages page) {
wait.defaultWait.until(ExpectedConditions.visibilityOf(sideBar));
public <T> T navigateTo(Pages page) {
LOG.debug("Get link to " + page.name());
// case SEARCH_RESOURCES:
// expandSection(resourcesExpandLnk);s
// return new DLink(driver, resourcesLnk);
// case ADMINISTRATION_EDIT_DOMAINS:
// expandSection(administrationExpand);
// return new DLink(driver, editDomainsLnk);
if (page == Pages.ADMINISTRATION_EDIT_DOMAINS) {
openSubmenu(administrationExpand, editDomainsLnk);
return (T) new EditDomainsPage(driver);
}
// case ADMINISTRATION_EDIT_GROUPS:
// expandSection(administrationExpand);
// return new DLink(driver, editGroupsLnk);
......@@ -135,25 +122,26 @@ public class SideNavigationComponent extends DomiSMPPage {
if (page == Pages.SYSTEM_SETTINGS_USERS) {
openSubmenu(systemSettingsExpand, usersLnk);
return new UsersPage(driver);
return (T) new UsersPage(driver);
}
if (page == Pages.SYSTEM_SETTINGS_DOMAINS) {
openSubmenu(systemSettingsExpand, domainsLnk);
return new DomainsPage(driver);
return (T) new DomainsPage(driver);
}
// case SYSTEM_SETTINGS_KEYSTORE:
// expandSection(systemSettingsExpand);
// return new DLink(driver, keystoreLnk);
// case SYSTEM_SETTINGS_TRUSTSTORE:
// expandSection(systemSettingsExpand);
// return new DLink(driver, truststoreLnk);
if (page == Pages.SYSTEM_SETTINGS_TRUSTSTORE) {
openSubmenu(systemSettingsExpand, truststoreLnk);
return (T) new TruststorePage(driver);
}
// case SYSTEM_SETTINGS_EXTENSIONS:
// expandSection(systemSettingsExpand);
// return new DLink(driver, extensionsLnk);
if (page == Pages.SYSTEM_SETTINGS_PROPERTIES) {
openSubmenu(systemSettingsExpand, propertiesLnk);
return new PropertiesPage(driver);
return (T) new PropertiesPage(driver);
}
// case SYSTEM_SETTINGS_ALERS:
......@@ -161,7 +149,7 @@ public class SideNavigationComponent extends DomiSMPPage {
// return new DLink(driver, alersLnk);
if (page == Pages.USER_SETTINGS_PROFILE) {
openSubmenu(userSettingsExpand, profileLnk);
return new ProfilePage(driver);
return (T) new ProfilePage(driver);
// case USER_SETTINGS_ACCESS_TOKEN:
// //expandSection(userSettingsExpand);
// //accessTokensLnk.click();
......@@ -176,7 +164,6 @@ public class SideNavigationComponent extends DomiSMPPage {
public Boolean isMenuAvailable(Pages page) {
MenuNavigation navigationLinks = getNavigationLinks(page);
try {
assert navigationLinks != null;
if (navigationLinks.menuLink.isEnabled()) {
navigationLinks.menuLink.click();
return navigationLinks.submenuLink.isEnabled();
......@@ -189,31 +176,46 @@ public class SideNavigationComponent extends DomiSMPPage {
}
private void openSubmenu(WebElement menuBtn, WebElement submenuBtn) {
try {
submenuBtn.click();
if (submenuBtn.getText().contains(getBreadcrump().getCurrentPage())) {
LOG.info("Current page is " + getBreadcrump().getCurrentPage());
} else {
LOG.error("Current page is not as expected. EXPECTED: [{}] but ACTUAL PAGE [{}]", submenuBtn.getText(), getBreadcrump().getCurrentPage());
throw new RuntimeException();
}
} catch (ElementNotInteractableException exception) {
// closeExpirationPopupIfEnabled();
if (!menuBtn.getAttribute("class").contains("cdk-focused")) {
menuBtn.click();
submenuBtn.click();
if (submenuBtn.getText().contains(getBreadcrump().getCurrentPage())) {
LOG.info("Current page is " + getBreadcrump().getCurrentPage());
}
submenuBtn.click();
if (submenuBtn.getText().contains(getBreadcrump().getCurrentPage())) {
LOG.info("Current page is " + getBreadcrump().getCurrentPage());
} else {
LOG.error("Current page is not as expected. EXPECTED: " + submenuBtn.getText() + "but ACTUAL PAGE: " + getBreadcrump().getCurrentPage());
throw new RuntimeException();
}
} else {
LOG.error("Current page is not as expected. EXPECTED: " + submenuBtn.getText() + "but ACTUAL PAGE: " + getBreadcrump().getCurrentPage());
throw new RuntimeException();
}
}
// private void openSubmenu(WebElement menuBtn, WebElement submenuBtn) {
// try {
// submenuBtn.click();
// if (submenuBtn.getText().contains(getBreadcrump().getCurrentPage())) {
// LOG.info("Current page is " + getBreadcrump().getCurrentPage());
//
// } else {
// LOG.error("Current page is not as expected. EXPECTED: [{}] but ACTUAL PAGE [{}]", submenuBtn.getText().toString(), getBreadcrump().getCurrentPage().toString());
// throw new RuntimeException();
// }
//
// } catch (ElementNotInteractableException exception) {
//
// // closeExpirationPopupIfEnabled();
// menuBtn.click();
// submenuBtn.click();
// if (submenuBtn.getText().contains(getBreadcrump().getCurrentPage())) {
// LOG.info("Current page is " + getBreadcrump().getCurrentPage());
//
// } else {
// LOG.error("Current page is not as expected. EXPECTED: " + submenuBtn.getText() + "but ACTUAL PAGE: " + getBreadcrump().getCurrentPage());
// throw new RuntimeException();
// }
// }
// }
public static class MenuNavigation {
WebElement menuLink;
WebElement submenuLink;
......
package ddsl.dcomponents;
package ddsl.dcomponents.commonComponents;
import ddsl.DomiSMPPage;
import ddsl.dcomponents.SetChangePasswordDialog;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -58,7 +59,7 @@ public class UserDataCommonComponent extends DomiSMPPage {
return passwordExpiresOnLbl.getText();
}
public SetChangePasswordDialog setChangePasswordDialog() {
public SetChangePasswordDialog getChangePasswordDialog() {
return new SetChangePasswordDialog(driver);
}
......@@ -71,8 +72,8 @@ public class UserDataCommonComponent extends DomiSMPPage {
if (!emailValue.isEmpty()) {
weToDInput(fullNameInput).fill(fullNameValue);
}
weToDSelect(themeSel).selectValue(selectThemeValue);
weToDSelect(localeSel).selectValue(localeValue);
weToDSelect(themeSel).selectByVisibleText(selectThemeValue);
weToDSelect(localeSel).selectByVisibleText(localeValue);
} catch (Exception e) {
......
package ddsl.dcomponents.commonComponents.members;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InviteMembersPopup extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(InviteMembersPopup.class);
@FindBy(id = "saveButton")
public WebElement saveBtn;
@FindBy(id = "member-user")
private WebElement selectMemberBtn;
@FindBy(css = "[formcontrolname=\"member-roleType\"]")
private WebElement selectMemberROleDdl;
public InviteMembersPopup(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getTIMEOUT()), this);
}
public void selectMember(String username, String role) {
LOG.debug("Inviting member {} with role {}", username, role);
selectMemberBtn.sendKeys(username);
selectMemberBtn.sendKeys(Keys.ARROW_DOWN);
selectMemberBtn.sendKeys(Keys.ENTER);
weToDSelect(selectMemberROleDdl).selectByVisibleText(role);
saveBtn.click();
}
public void changeRole(String newRole) {
if (!weToDSelect(selectMemberROleDdl).getCurrentValue().equals(newRole)) {
weToDSelect(selectMemberROleDdl).selectByVisibleText(newRole);
LOG.debug("Changing role to {}", newRole);
}
saveBtn.click();
}
}
package ddsl.dcomponents.commonComponents.members;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dcomponents.DComponent;
import ddsl.dcomponents.Grid.SmallGrid;
import ddsl.dobjects.DButton;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MembersComponent extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(MembersComponent.class);
@FindBy(id = "addMemberButton")
private WebElement inviteMemberBtn;
@FindBy(id = "deleteButton")
private WebElement removeMemberBtn;
@FindBy(css = "div domain-member-panel")
private WebElement sidePanel;
public MembersComponent(WebDriver driver) {
super(driver);
LOG.debug("Members component is loaded");
//wait.forElementToBeVisible(inviteMemberBtn);
}
public SmallGrid getMembersGrid() {
return new SmallGrid(driver, sidePanel);
}
public InviteMembersPopup getInviteMembersPopup() {
return new InviteMembersPopup(driver);
}
public DButton getInviteMemberBtn() {
return weToDButton(inviteMemberBtn);
}
public void removeUser(String username) throws Exception {
getMembersGrid().searchValueInColumn("Username", username).click();
weToDButton(removeMemberBtn).click();
ConfirmationDialog confirmationDialog = new ConfirmationDialog(driver);
confirmationDialog.confirm();
}
public void changeRoleOfUser(String username, String newRole) throws Exception {
getMembersGrid().searchValueInColumn("Username", username).click();
weToDButton(sidePanel.findElement(By.id("editButton"))).click();
getInviteMembersPopup().changeRole(newRole);
}
}
......@@ -15,10 +15,13 @@ public class DSelect extends DObject {
super(driver, element);
}
public void selectValue(String value) {
public void selectByVisibleText(String value) {
select.selectByVisibleText(value);
}
public void selectValue(String value) {
select.selectByValue(value);
}
public String getCurrentValue() {
return select.getAllSelectedOptions().get(0).getText();
}
......
......@@ -17,6 +17,10 @@ public class DWait {
private final static Logger LOG = LoggerFactory.getLogger(DWait.class);
/**
* Wait class which gives access to different types of waits.
*/
public final WebDriverWait defaultWait;
public final WebDriverWait longWait;
public final WebDriverWait shortWait;
......
package ddsl.enums;
import java.util.Random;
public enum ResourceTypes {
OASIS1("edelivery-oasis-smp-1.0-servicegroup (smp-1)"),
OASIS2("edelivery-oasis-smp-2.0-servicegroup (oasis-bdxr-smp-2)"),
OASIS3("edelivery-oasis-cppa-3.0-cpp (cpp)");
public String getName() {
return name;
}
public final String name;
......@@ -16,12 +18,5 @@ public enum ResourceTypes {
}
public static String getRandomResourceType() {
ResourceTypes[] resourceTypes = values();
int size = resourceTypes.length;
Random random = new Random();
int index = random.nextInt(size);
return resourceTypes[index].name;
}
}
package ddsl.enums;
import java.util.Random;
public enum ResponseCertificates {
SMP_DOMAIN_02("smp_domain_02 (CN=smp_domain_02,O=digit,C=eu:000000006443d987)"),
SMP_EDDSA_448("smp_eddsa_448 (CN=smp_eddsa_448,O=digit,C=eu:000000006443fcba)"),
SMP_ECDSA_NIST_B409("smp_ecdsa_nist-b409 (CN=smp_ecdsa_nist-b409,O=digit,C=eu:000000006443fd57)"),
SMP_DOMAIN_01("smp_domain_01 (CN=smp_domain_01,O=digit,C=eu:000000006443d8a8"),
SAMPLE_KEY("sample_key (CN=demo-smp-signing-key,O=digit,C=eu:000000006443f9bc"),
SMP_EDDSA_25519("smp_eddsa_25519 (CN=smp_eddsa_25519,O=digit,C=eu:000000006443d95d");
SMP_DOMAIN_01("smp_domain_01 (CN=smp_domain_01,O=digit,C=eu:000000006443d8a8)"),
SAMPLE_KEY("sample_key (CN=demo-smp-signing-key,O=digit,C=eu:000000006443f9bc)"),
SMP_EDDSA_25519("smp_eddsa_25519 (CN=smp_eddsa_25519,O=digit,C=eu:000000006443d95d)");
public String getName() {
return name;
}
public final String name;
ResponseCertificates(String name) {
this.name = name;
}
public static String getRandomCertificate() {
ResponseCertificates[] certificates = values();
int size = certificates.length;
Random random = new Random();
int index = random.nextInt(size);
return certificates[index].name;
}
}
package pages.DomainsPage;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rest.models.DomainModel;
public class DomainTab extends DComponent {
/**
* Page object for the Domains tab of Domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(DomainTab.class);
@FindBy(id = "domainCode_id")
private WebElement domainIdInput;
@FindBy(id = "signatureKeyAlias_id")
private WebElement responseSignatureCertificateDdl;
@FindBy(id = "domainVisibility_id")
private WebElement visibilityOfDomainDdl;
@FindBy(id = "saveButton")
private WebElement saveBtn;
public DomainTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getTIMEOUT()), this);
}
public WebElement getDomainIdInput() {
return domainIdInput;
}
public String getResponseSignatureCertificateSelectedValue() {
return weToDSelect(responseSignatureCertificateDdl).getCurrentValue();
}
public String getVisibilityOfDomainSelectedValue() {
return weToDSelect(visibilityOfDomainDdl).getCurrentValue().toUpperCase();
}
public void fillDomainData(DomainModel domainModel) {
domainIdInput.sendKeys(domainModel.getDomainCode());
weToDSelect(responseSignatureCertificateDdl).selectByVisibleText(domainModel.getSignatureKeyAlias());
weToDSelect(visibilityOfDomainDdl).selectValue(domainModel.getVisibility());
}
public void saveChanges() {
if (saveBtn.isEnabled()) {
saveBtn.click();
wait.forElementToBeDisabled(saveBtn);
if (saveBtn.getAttribute("disabled").equals("true")) {
LOG.debug("Domain tab changes were succesfully saved");
} else {
LOG.error("Domain tab changes were not saved");
}
}
}
}
\ No newline at end of file
......@@ -7,40 +7,21 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rest.models.DomainModel;
import java.util.List;
public class DomainsPage extends PageWithGrid {
/**
* Page object for the Users page. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(DomainsPage.class);
@FindBy(id = "domainCode_id")
private WebElement domainIdInput;
@FindBy(id = "signatureKeyAlias_id")
private WebElement responseSignatureCertificateDdl;
@FindBy(id = "domainVisibility_id")
private WebElement visibilityOfDomainDdl;
@FindBy(id = "saveButton")
private WebElement saveBtn;
@FindBy(css = "[role = \"tab\"] ")
private List<WebElement> tabList;
private ResourceTab resourceTab;
@FindBy(css = "smp-warning-panel span")
private WebElement warningLabel;
public DomainsPage(WebDriver driver) {
super(driver);
LOG.debug("Loading Domains page.");
}
public DButton getCreateDomainBtn() {
return new DButton(driver, AddBtn);
return new DButton(driver, addBtn);
}
public ResourceTab getResourceTab() {
......@@ -48,26 +29,23 @@ public class DomainsPage extends PageWithGrid {
return new ResourceTab(driver);
}
public DomainTab getDomainTab() {
public void fillDomainData(DomainModel domainModel) {
return new DomainTab(driver);
}
domainIdInput.sendKeys(domainModel.getDomainCode());
weToDSelect(responseSignatureCertificateDdl).selectValue(domainModel.getSignatureKeyAlias());
public SMLIntegrationTab getSMLIntegrationTab() {
return new SMLIntegrationTab(driver);
}
public String saveChangesAndGetMessage() {
saveBtn.click();
return getAlertArea().getAlertMessage();
public MembersTab getMembersTab() {
return new MembersTab(driver);
}
public void goToTab(String tabName) {
for (WebElement element : tabList) {
if (element.getText().contains(tabName)) {
element.click();
wait.forAttributeToContain(element, "aria-selected", "true");
LOG.debug("Domain tab {} is opened", tabName);
}
}
public String getDomainWarningMessage() {
return warningLabel.getText();
}
......
package pages.DomainsPage;
import ddsl.dcomponents.commonComponents.members.MembersComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
public class MembersTab extends MembersComponent {
public MembersTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getTIMEOUT()), this);
}
}
......@@ -14,7 +14,7 @@ import java.util.List;
public class ResourceTab extends DComponent {
/**
* Resource tab component of Domain page. Gives access to resource tab behaviour.
* Page object for the Resource tab of Domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(ResourceTab.class);
......@@ -35,12 +35,11 @@ public class ResourceTab extends DComponent {
saveBtn.click();
if (saveBtn.getAttribute("disabled").equals("truw")) {
LOG.debug("Resource tab changes were succesfully saved");
} else {
LOG.error("Resource tab changes were not saved");
}
LOG.debug("Resource tab changes were not saved");
}
}
public void checkResource(String resourceName) {
wait.forElementToBeClickable(resourceOptions.get(0));
for (WebElement element : resourceOptions) {
......
package pages.DomainsPage;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rest.models.DomainModel;
public class SMLIntegrationTab extends DComponent {
/**
* Page object for the SML integration tab of Domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(SMLIntegrationTab.class);
@FindBy(id = "smldomain_id")
private WebElement smlDomainInput;
@FindBy(id = "smlSMPId_id")
private WebElement smlsmpIdentifierInput;
@FindBy(id = "smlClientKeyAlias_id")
private WebElement smlClientCertificateAliasDdl;
@FindBy(id = "smlClientCertHeaderAuth_id-button")
private WebElement useClientCertBtn;
@FindBy(id = "saveButton")
private WebElement saveBtn;
@FindBy(id = "registerButton")
private WebElement registerBtn;
public SMLIntegrationTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getTIMEOUT()), this);
}
public void fillSMLIntegrationTab(DomainModel domainModel) {
try {
weToDInput(smlDomainInput).fill(domainModel.getSmlSubdomain());
weToDInput(smlsmpIdentifierInput).fill(domainModel.getSmlSmpId());
//TODO : check of clientcertificatealias is changed from mat-select to select
weToDSelect(smlClientCertificateAliasDdl).selectByVisibleText(domainModel.getSignatureKeyAlias());
weToDButton(useClientCertBtn).click();
} catch (Exception e) {
LOG.error("Cannot fill SML integration data");
throw new RuntimeException(e);
}
}
public void saveChanges() {
if (saveBtn.isEnabled()) {
saveBtn.click();
wait.forElementToBeDisabled(saveBtn);
if (saveBtn.getAttribute("disabled").equals("true")) {
LOG.debug("SML Integration tab changes were succesfully saved");
} else {
LOG.error("SML Integration tab changes were not saved");
}
}
}
public void registerToSML() throws Exception {
try {
if (weToDButton(registerBtn).isEnabled()) {
weToDButton(registerBtn).click();
ConfirmationDialog confirmationDialog = new ConfirmationDialog(driver);
confirmationDialog.confirm();
}
} catch (Exception e) {
LOG.error("Register button is not enabled");
throw new Exception(e);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment