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

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

Pull request #36: EDELIVERY-12091 Progress on the automation of the DomiSMP UI tests Part 5

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

* commit '56c9de89':
  resolved PR comments
  added rest call for AddResourceToDomain
  added Matselect wrapper, added EditGroupsPage
  created common page with tabs, created pages for EditGroups.
  fixed test TRST-01 System admin is able to import certificates ADDED TRST-02 System admin is able to import duplicated certificates
parents 037032d5 56c9de89
No related branches found
No related tags found
No related merge requests found
Pipeline #104101 passed with warnings
Showing
with 198 additions and 123 deletions
......@@ -3,11 +3,10 @@ package ddsl;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class CommonCertificatePage extends CommonPageWithGrid {
/**
* Common page used for Keystore and Truststore
*/
/**
* Common page used for Keystore and Truststore
*/
public class CommonCertificatePage extends CommonPageWithTabsAndGrid {
@FindBy(id = "publicKeyType_id")
private WebElement publicKeyTypeLbl;
@FindBy(id = "alias_id")
......@@ -34,38 +33,38 @@ public class CommonCertificatePage extends CommonPageWithGrid {
}
public String getPublicKeyTypeLbl() {
return publicKeyTypeLbl.getText();
return weToDInput(publicKeyTypeLbl).getText();
}
public String getAliasIdLbl() {
return aliasIdLbl.getText();
return weToDInput(aliasIdLbl).getText();
}
public String getSmpCertificateIdLbl() {
return smpCertificateIdLbl.getText();
return weToDInput(smpCertificateIdLbl).getText();
}
public String getSubjectNameLbl() {
return subjectNameLbl.getText();
return weToDInput(subjectNameLbl).getText();
}
public String getValidFromLbl() {
return validFromLbl.getText();
return weToDInput(validFromLbl).getText();
}
public String getValidToLbl() {
return validToLbl.getText();
return weToDInput(validToLbl).getText();
}
public String getIssuerLbl() {
return issuerLbl.getText();
return weToDInput(issuerLbl).getText();
}
public String getSerialNumberLbl() {
return serialNumberLbl.getText();
return weToDInput(serialNumberLbl).getText();
}
public String getCertificateRevolcationListURLlbl() {
return certificateRevolcationListURLlbl.getText();
return weToDInput(certificateRevolcationListURLlbl).getText();
}
}
package ddsl;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
/**
* Generic page used for pages which have tabs in the left part. This element gives access to action buttons and elements of the page.
*/
public class CommonPageWithTabs extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(CommonPageWithTabs.class);
@FindBy(css = "[role = \"tab\"]")
private List<WebElement> tabList;
public CommonPageWithTabs(WebDriver driver) {
super(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);
break;
}
}
}
public String getAlertMessageAndClose() {
return getAlertArea().getAlertMessage();
}
}
......@@ -8,52 +8,27 @@ 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 CommonPageWithGrid extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(CommonPageWithGrid.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.
*/
/**
* Generic page used for pages which have small grid in the right of the page and tabs in the left. This element gives access to action buttons and elements of the page.
*/
public class CommonPageWithTabsAndGrid extends CommonPageWithTabs {
private final static Logger LOG = LoggerFactory.getLogger(CommonPageWithTabsAndGrid.class);
@FindBy(css = "mat-form-field input")
public WebElement filterInput;
@FindBy(css = "data-panel >div >div> mat-toolbar button:first-of-type")
public WebElement addBtn;
@FindBy(css = "[class=smp-column-data]")
public WebElement dataPanel;
@FindBy(css = "[class~=smp-column-label]")
public WebElement rightPanel;
@FindBy(css = "[role = \"tab\"]")
private List<WebElement> tabList;
public CommonPageWithGrid(WebDriver driver) {
public CommonPageWithTabsAndGrid(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
LOG.debug("CommonPageWithTabs is loaded");
}
public SmallGrid getGrid() {
return new SmallGrid(driver, rightPanel);
}
public SmallGrid getDataPanelGrid() {
public SmallGrid getLeftSideGrid() {
return new SmallGrid(driver, rightPanel);
}
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();
}
}
......@@ -16,12 +16,10 @@ import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.LoginPage;
/**
* Page object for the common components from Domismp like navigation, right menu. This contains the locators of the page and the methods for the behaviour of the page
*/
public class DomiSMPPage extends DComponent {
/**
* Page object for the common components from Domismp like navigation, right menu. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(DomiSMPPage.class);
@FindBy(css = "cdk-overlay-backdrop cdk-overlay-dark-backdrop cdk-overlay-backdrop-showing")
protected WebElement overlay;
......@@ -34,6 +32,9 @@ public class DomiSMPPage extends DComponent {
@FindBy(css = "#okbuttondialog_id ")
private WebElement dialogOKbutton;
private AlertComponent alertComponent = null;
public DomiSMPPage(WebDriver driver) {
super(driver);
......@@ -70,9 +71,16 @@ public class DomiSMPPage extends DComponent {
driver.navigate().refresh();
waitForPageToLoaded();
}
public AlertComponent getAlertArea() {
return new AlertComponent(driver);
//
// public AlertComponent getAlertArea() {
// return new AlertComponent(driver);
// }
public AlertComponent getAlertArea(){
if ( alertComponent == null){
alertComponent = new AlertComponent(driver);
}
return alertComponent;
}
public DButton getExpiredDialoginbutton() {
......
......@@ -7,13 +7,11 @@ import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Page component for conformation popups/dialogs for different actions
*/
public class ConfirmationDialog extends DComponent {
/**
* Page component for conformation popups/dialogs for different actions
*/
private final static Logger LOG = LoggerFactory.getLogger(ConfirmationDialog.class);
@FindBy(id = "yesbuttondialog_id")
private WebElement yesBtn;
@SuppressWarnings("SpellCheckingInspection")
......
......@@ -8,17 +8,13 @@ import ddsl.dobjects.DWait;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import utils.TestRunData;
/**
* Generic component which gives access of driver, wait and wrappers of elements. This should be inhered by each component class.
*/
public class DComponent {
/**
* Generic component which gives access of driver, wait and wrappers of elements. This should be inhered by each component class.
*/
public DWait wait;
protected WebDriver driver;
protected TestRunData data = TestRunData.getInstance();
public DComponent(WebDriver driver) {
this.driver = driver;
this.wait = new DWait(driver);
......
......@@ -12,12 +12,10 @@ import pages.userSettings.SuccesfullPasswordChangedPopup;
import java.util.ArrayList;
import java.util.List;
/**
* Page object for the Set/change password dialog. This contains the locators of the page and the methods for the behaviour of the page
*/
public class SetChangePasswordDialog extends DComponent {
/**
* 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;
......@@ -44,7 +42,7 @@ public class SetChangePasswordDialog extends DComponent {
weToDInput(confirmationPasswordInput).fill(newPassword, true);
}
public DomiSMPPage TryClickOnChangePassword() throws Exception {
public DomiSMPPage TryClickOnChangePassword(){
wait.forElementToBeClickable(setPasswordBtn);
if (weToDButton(setPasswordBtn).isEnabled() && fieldsError.isEmpty()) {
weToDButton(setPasswordBtn).click();
......
......@@ -12,6 +12,7 @@ import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.administration.editDomainsPage.EditDomainsPage;
import pages.administration.editGroupsPage.EditGroupsPage;
import pages.systemSettings.TruststorePage;
import pages.systemSettings.UsersPage;
import pages.systemSettings.domainsPage.DomainsPage;
......@@ -20,14 +21,11 @@ import pages.systemSettings.propertiesPage.PropertiesPage;
import pages.userSettings.ProfilePage;
import java.util.Objects;
/**
* Navigation object to navigate through application.
*/
public class SideNavigationComponent extends DomiSMPPage {
/**
* Navigation object to navigate through application.
*/
private final static Logger LOG = LoggerFactory.getLogger(SideNavigationComponent.class);
@FindBy(id = "window-sidenav-panel")
public WebElement sideBar;
......@@ -119,10 +117,12 @@ public class SideNavigationComponent extends DomiSMPPage {
openSubmenu(administrationExpand, editDomainsLnk);
return (T) new EditDomainsPage(driver);
}
if (page == Pages.ADMINISTRATION_EDIT_GROUPS) {
openSubmenu(administrationExpand, editGroupsLnk);
return (T) new EditGroupsPage(driver);
}
// case ADMINISTRATION_EDIT_GROUPS:
// expandSection(administrationExpand);
// return new DLink(driver, editGroupsLnk);
// case ADMINISTRATION_EDIT_RESOURCES:
// expandSection(administrationExpand);
// return new DLink(driver, editResourcesLnk);
......
......@@ -7,12 +7,10 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Common component for user data used in Profile and Users page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class UserDataCommonComponent extends DomiSMPPage {
/**
* Common component for user data used in Profile and 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(UserDataCommonComponent.class);
@FindBy(id = "changePassword_id")
private WebElement setChangePasswordBtn;
......@@ -59,7 +57,7 @@ public class UserDataCommonComponent extends DomiSMPPage {
return passwordExpiresOnLbl.getAttribute("value");
}
public SetChangePasswordDialog clickOnChangePassword() throws InterruptedException {
public SetChangePasswordDialog clickOnChangePassword(){
setChangePasswordBtn.click();
return new SetChangePasswordDialog(driver);
}
......
......@@ -9,8 +9,12 @@ import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generic component for Invite members popup. It contains the WebElements and the methods specific to the dialog.
*
*/
public class InviteMembersPopup extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(InviteMembersPopup.class);
@FindBy(id = "saveButton")
public WebElement saveBtn;
......
......@@ -10,8 +10,12 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generic component for Members tab. It contains the WebElements and the methods specific to the dialog.
*
*/
public class MembersComponent extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(MembersComponent.class);
@FindBy(id = "addMemberButton")
......@@ -38,14 +42,14 @@ public class MembersComponent extends DComponent {
return weToDButton(inviteMemberBtn);
}
public void removeUser(String username) throws Exception {
public void removeUser(String username){
getMembersGrid().searchAndGetElementInColumn("Username", username).click();
weToDButton(removeMemberBtn).click();
ConfirmationDialog confirmationDialog = new ConfirmationDialog(driver);
confirmationDialog.confirm();
}
public void changeRoleOfUser(String username, String newRole) throws Exception {
public void changeRoleOfUser(String username, String newRole){
getMembersGrid().searchAndGetElementInColumn("Username", username).click();
weToDButton(sidePanel.findElement(By.id("editButton"))).click();
getInviteMembersPopup().changeRole(newRole);
......
package ddsl.dcomponents.commonComponents.subcategoryTab;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dcomponents.DComponent;
import ddsl.dcomponents.Grid.SmallGrid;
import org.apache.poi.ss.formula.functions.T;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generic component for Subcategory tabs. It contains the WebElements and the methods specific to the dialog.
*
*/
public class SubcategoryTabComponent extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(SubcategoryTabComponent.class);
@FindBy(id = "createButton")
......@@ -20,27 +25,34 @@ public class SubcategoryTabComponent extends DComponent {
private WebElement resourceMembersBtn;
@FindBy(id = "deleteButton")
private WebElement deleteBtn;
@FindBy(css = "div smp-column-data")
private WebElement sidePanel;
@FindBy(css = "[class=smp-column-data]")
private WebElement rightSidePanel;
public SubcategoryTabComponent(WebDriver driver) {
super(driver);
}
public SmallGrid getGrid() {
return new SmallGrid(driver, sidePanel);
return new SmallGrid(driver, rightSidePanel);
}
public DComponent create() throws Exception {
public void create() throws ElementNotInteractableException {
weToDButton(createBtn).click();
return new DComponent(driver);
}
public T edit(String columnName, String value) throws Exception {
protected void edit(String columnName, String value) throws Exception {
WebElement tobeEdited = getGrid().searchAndGetElementInColumn(columnName, value);
tobeEdited.click();
wait.forElementToBeEnabled(editBtn);
weToDButton(editBtn).click();
return new T();
}
protected void delete(String columnName, String value){
WebElement tobeDeleted = getGrid().searchAndGetElementInColumn(columnName, value);
tobeDeleted.click();
wait.forElementToBeEnabled(deleteBtn);
weToDButton(deleteBtn).click();
ConfirmationDialog confirmationDialog = new ConfirmationDialog(driver);
confirmationDialog.confirm();
}
}
......@@ -3,15 +3,13 @@ package ddsl.dobjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
/**
* Generic wrapper for button element.
*/
public class DButton extends DObject {
/**
* Generic wrapper for button element.
*/
public DButton(WebDriver driver, WebElement element) {
super(driver, element);
}
@Override
public String getText() {
return element.findElement(By.cssSelector("span > span")).getText().trim();
......
......@@ -3,16 +3,15 @@ package ddsl.dobjects;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
/**
* Generic wrapper for input element.
*/
public class DInput extends DObject {
/**
* Generic wrapper for input element.
*/
public DInput(WebDriver driver, WebElement element) {
super(driver, element);
}
public void fill(String value) throws Exception {
public void fill(String value){
if (null == value) {
return;
}
......@@ -27,7 +26,7 @@ public class DInput extends DObject {
/**
* Method to send values which are bigger which can't be handled by Angular issue
*/
public void fill(String value, Boolean slowSendValues) throws Exception {
public void fill(String value, Boolean slowSendValues){
if (null == value) {
return;
}
......@@ -37,7 +36,7 @@ public class DInput extends DObject {
if (slowSendValues) {
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
String s = new StringBuilder().append(c).toString();
String s = String.valueOf(c);
element.sendKeys(s);
}
} else {
......
......@@ -2,11 +2,10 @@ package ddsl.dobjects;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
/**
* Generic wrapper for link element.
*/
public class DLink extends DObject {
/**
* Generic wrapper for link element.
*/
public DLink(WebDriver driver, WebElement element) {
super(driver, element);
}
......
package ddsl.dobjects;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generic element object used to have access to element actions.
*/
public class DObject {
/**
* Generic element object used to have access to element actions.
*/
protected final Logger log = LoggerFactory.getLogger(this.getClass());
public WebElement element;
protected WebDriver driver;
protected DWait wait;
public DObject(WebDriver driver, WebElement element) {
wait = new DWait(driver);
this.driver = driver;
......@@ -31,12 +30,18 @@ public class DObject {
return true;
}
public boolean isEnabled() throws Exception {
if (isPresent()) {
wait.forElementToBeEnabled(element);
return element.isEnabled();
public boolean isEnabled() throws ElementNotInteractableException {
try {
if (isPresent()) {
wait.forElementToBeEnabled(element);
return element.isEnabled();
}
}
throw new Exception();
catch (ElementNotInteractableException e){
throw new ElementNotInteractableException("Element not enabled: "+ e);
}
return false;
}
public boolean isDisabled() throws Exception {
......@@ -68,11 +73,11 @@ public class DObject {
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
}
public void click() throws Exception {
public void click() throws ElementNotInteractableException {
if (isEnabled()) {
wait.forElementToBeClickable(element).click();
} else {
throw new Exception(element.getAccessibleName() + "Not enabled");
throw new ElementNotInteractableException(element.getAccessibleName() + "Not enabled");
}
}
......
......@@ -5,17 +5,14 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
/**
* Generic wrapper for select element.
*/
public class DSelect extends DObject {
/**
* Generic wrapper for select element.
*/
Select select = new Select(element);
public DSelect(WebDriver driver, WebElement element) {
super(driver, element);
}
public void selectByVisibleText(String value) {
select.selectByVisibleText(value);
}
......
......@@ -9,18 +9,11 @@ import org.slf4j.LoggerFactory;
import utils.TestRunData;
import java.time.Duration;
/**
* Wait class util used to have access to different types of waits.
*/
public class DWait {
/**
* Wait class util used to have access to different types of waits.
*/
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;
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)");
OASIS1("edelivery-oasis-smp-1.0-servicegroup"),
OASIS2("edelivery-oasis-smp-2.0-servicegroup"),
OASIS3("edelivery-oasis-cppa-3.0-cpp");
public String getName() {
return name;
}
public final String name;
private final String name;
ResourceTypes(String name) {
......
......@@ -10,15 +10,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
/**
* Page object for the Login page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class LoginPage extends DomiSMPPage {
/**
* Page object for the Login page. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(LoginPage.class);
@FindBy(id = "username_id")
private WebElement username;
@FindBy(id = "password_id")
......
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