Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/EDELIVERY-12091-Progress-on-the-automation-of-the-DomiSMP-UI-tests---Part-5' into EDELIVERY-12247-Automate_new_SMP_UI_testcases-part_4

# Conflicts:
#	domiSMP-ui-tests/src/main/java/ddsl/CommonCertificatePage.java
#	domiSMP-ui-tests/src/main/java/ddsl/dcomponents/DComponent.java
#	domiSMP-ui-tests/src/test/java/domiSMPTests/ui/KeystorePgTests.java
parents e337e1fd 69b9c32d
No related branches found
No related tags found
No related merge requests found
Showing
with 479 additions and 57 deletions
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;
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);
}
}
}
public String getAlertMessageAndClose() {
return getAlertArea().getAlertMessage();
}
}
......@@ -9,10 +9,8 @@ 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);
public class CommonPageWithTabsAndGrid extends CommonPageWithTabs {
private final static Logger LOG = LoggerFactory.getLogger(CommonPageWithTabsAndGrid.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.
......@@ -22,38 +20,17 @@ public class CommonPageWithGrid extends DomiSMPPage {
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);
}
public SmallGrid getGrid() {
public SmallGrid getLeftSideGrid() {
return new SmallGrid(driver, rightPanel);
}
public SmallGrid getDataPanelGrid() {
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();
}
}
......@@ -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;
......@@ -119,10 +120,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);
......
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.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -20,27 +20,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 Exception {
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) throws Exception {
WebElement tobeDeleted = getGrid().searchAndGetElementInColumn(columnName, value);
tobeDeleted.click();
wait.forElementToBeEnabled(deleteBtn);
weToDButton(deleteBtn).click();
ConfirmationDialog confirmationDialog = new ConfirmationDialog(driver);
confirmationDialog.confirm();
}
}
package ddsl.dobjects;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dcomponents.DComponent;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class DMatSelect extends DComponent {
/**
* Generic wrapper for select element.
*/
private final static Logger LOG = LoggerFactory.getLogger(ConfirmationDialog.class);
public WebElement selectContainer;
protected List<String> optionIDs = new ArrayList<String>();
@FindBy(css = "[class*=\"select-arrow\"]")
protected WebElement expandBtn;
private By options = By.cssSelector("div > mat-option");
private By selectedOption = By.cssSelector("[class*=\"-select-value\"]");
public DMatSelect(WebDriver driver, WebElement container) {
super(driver);
wait.forXMillis(100);
PageFactory.initElements(new AjaxElementLocatorFactory(container, data.getWaitTimeShort()), this);
this.selectContainer = container;
// try {
// if (isDisplayed() && isEnabled()) {
// weToDButton(expandBtn).click();
// extractOptionIDs();
// contract();
// }
// } catch (Exception e) {
// }
}
public boolean isDisplayed() throws Exception {
try {
return weToDButton(expandBtn).isEnabled();
} catch (Exception e) {
return false;
}
}
public boolean isEnabled() {
// aria-disabled="true"
boolean isEnabled = true;
try {
isEnabled = !Boolean.valueOf((selectContainer).getAttribute("aria-disabled"));
} catch (Exception e) {
}
return isEnabled;
}
private void extractOptionIDs() throws Exception {
wait.forAttributeToContain(selectContainer, "aria-owns", "mat-option");
String[] ids = selectContainer.getAttribute("aria-owns").split(" ");
optionIDs.addAll(Arrays.asList(ids));
// log.debug(optionIDs.size() + " option ids identified : " + optionIDs);
}
// private void expand() throws Exception {
// try {
// weToDButton(expandBtn).click();
// wait.forAttributeNotEmpty(selectContainer, "aria-owns");
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
private void contract() throws Exception {
try {
wait.forXMillis(200);
selectContainer.sendKeys(Keys.ESCAPE);
wait.forXMillis(200);
} catch (Exception e) {
}
}
// -----------------------------------------------------------------
protected List<DObject> getOptionElements() throws Exception {
weToDButton(expandBtn).click();
List<DObject> optionObj = new ArrayList<>();
for (int i = 0; i < optionIDs.size(); i++) {
String optionId = optionIDs.get(i);
WebElement option = driver.findElement(By.id(optionId));
optionObj.add(new DObject(driver, option));
}
return optionObj;
}
public boolean selectOptionByText(String text) throws Exception {
LOG.debug("selecting option by text: " + text);
if (StringUtils.isEmpty(text)) {
return false;
}
List<DObject> optionObj = getOptionElements();
if (optionObj.size() == 0) {
LOG.warn("select has no options ");
}
for (DObject dObject : optionObj) {
if (StringUtils.equalsIgnoreCase(dObject.getText(), text)) {
dObject.click();
return true;
}
}
return false;
}
public boolean deselectOptionByText(String text) throws Exception {
LOG.debug("selecting option by text: " + text);
if (StringUtils.isEmpty(text)) {
return false;
}
List<DObject> optionObj = getOptionElements();
if (optionObj.size() == 0) {
LOG.warn("select has no options ");
}
for (DObject dObject : optionObj) {
if (StringUtils.equalsIgnoreCase(dObject.getText(), text)) {
dObject.click();
if (dObject.getAttribute("aria-selected").equals(true)) {
return true;
}
}
}
return false;
}
public List<String> getOptionsTexts() throws Exception {
List<String> texts = new ArrayList<>();
List<DObject> options = getOptionElements();
for (int i = 0; i < options.size(); i++) {
texts.add(options.get(i).getText());
}
contract();
return texts;
}
}
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) {
......
package pages.administration.editDomainsPage;
import ddsl.dcomponents.AlertComponent;
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 rest.models.GroupModel;
public class CreateGroupDetailsDialog extends DComponent {
@FindBy(id = "name_id")
private WebElement groupNameLbl;
@FindBy(id = "description_id")
private WebElement groupDescriptionLbl;
@FindBy(id = "group_id")
private WebElement groupVisibilityDdl;
@FindBy(id = "saveButton")
private WebElement saveBtn;
public CreateGroupDetailsDialog(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public AlertComponent getAlertArea() {
return new AlertComponent(driver);
}
public void fillGroupDetails(GroupModel group) {
groupNameLbl.sendKeys(group.getGroupName());
groupDescriptionLbl.sendKeys(group.getGroupDescription());
weToDSelect(groupVisibilityDdl).selectValue(group.getVisibility());
}
public Boolean tryClickOnSave() throws Exception {
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
return true;
} else {
return false;
}
}
}
package pages.administration.editDomainsPage;
import ddsl.CommonPageWithGrid;
import ddsl.CommonPageWithTabsAndGrid;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EditDomainsPage extends CommonPageWithGrid {
public class EditDomainsPage extends CommonPageWithTabsAndGrid {
/**
* Page object for the Edit domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
......@@ -21,4 +21,10 @@ public class EditDomainsPage extends CommonPageWithGrid {
return new DomainMembersTab(driver);
}
public GroupTab getGroupTab() {
return new GroupTab(driver);
}
}
......@@ -2,14 +2,28 @@ package pages.administration.editDomainsPage;
import ddsl.dcomponents.commonComponents.subcategoryTab.SubcategoryTabComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
public class GroupTab extends SubcategoryTabComponent {
public GroupTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public CreateGroupDetailsDialog clickCreateNewGroup() throws Exception {
create();
return new CreateGroupDetailsDialog(driver);
}
@Override
public CreateGroupDetailsDialog create() {
public CreateGroupDetailsDialog clickEditGroup(String domainCode) throws Exception {
edit("Group name", domainCode);
return new CreateGroupDetailsDialog(driver);
}
public void deleteGroup(String domainCode) throws Exception {
delete("Group name", domainCode);
}
}
package pages.administration.editGroupsPage;
import ddsl.CommonPageWithTabs;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rest.models.DomainModel;
import rest.models.GroupModel;
public class EditGroupsPage extends CommonPageWithTabs {
/**
* Page object for the Edit groups page. This contains the locators of the page and the methods for the behaviour of the page
*/
private final static Logger LOG = LoggerFactory.getLogger(EditGroupsPage.class);
@FindBy(id = "domain_id")
private WebElement domainDdl;
@FindBy(id = "group_id")
private Select groupDdl;
public EditGroupsPage(WebDriver driver) {
super(driver);
LOG.debug("Loading Edit groups page.");
}
public void selectGroup(DomainModel domainModel, GroupModel groupModel) throws Exception {
weToMatDSelect(domainDdl).selectOptionByText(domainModel.getDomainCode());
}
public GroupMembersTab getDomainMembersTab() {
return new GroupMembersTab(driver);
}
public ResourceTab getGroupTab() {
return new ResourceTab(driver);
}
}
package pages.administration.editGroupsPage;
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 GroupMembersTab extends MembersComponent {
public GroupMembersTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
}
package pages.administration.editGroupsPage;
import ddsl.dcomponents.commonComponents.subcategoryTab.SubcategoryTabComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.administration.editDomainsPage.CreateGroupDetailsDialog;
public class ResourceTab extends SubcategoryTabComponent {
public ResourceTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public CreateGroupDetailsDialog clickOnCreateNewResource() throws Exception {
create();
return new CreateGroupDetailsDialog(driver);
}
}
package pages.systemSettings;
import ddsl.CommonCertificatePage;
import ddsl.dcomponents.Grid.SmallGrid;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -20,7 +21,9 @@ public class TruststorePage extends CommonCertificatePage {
super(driver);
}
public SmallGrid getCertificateGrid() {
return new SmallGrid(driver, rightPanel);
}
public String addCertificateAndReturnAlias(String filePath) {
uploadInput.sendKeys(filePath);
String certificateAlias = getAlertMessageAndClose();
......
package pages.systemSettings;
import ddsl.CommonPageWithGrid;
import ddsl.CommonPageWithTabsAndGrid;
import ddsl.dcomponents.commonComponents.UserDataCommonComponent;
import ddsl.dobjects.DButton;
import org.openqa.selenium.WebDriver;
......@@ -10,7 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rest.models.UserModel;
public class UsersPage extends CommonPageWithGrid {
public class UsersPage extends CommonPageWithTabsAndGrid {
/**
* Page object for the Users page. This contains the locators of the page and the methods for the behaviour of the page
*/
......
package pages.systemSettings.domainsPage;
import ddsl.CommonPageWithGrid;
import ddsl.CommonPageWithTabsAndGrid;
import ddsl.dobjects.DButton;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
......@@ -8,7 +8,7 @@ import org.openqa.selenium.support.FindBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DomainsPage extends CommonPageWithGrid {
public class DomainsPage extends CommonPageWithTabsAndGrid {
/**
* Page object for the Users page. This contains the locators of the page and the methods for the behaviour of the page
*/
......
......@@ -78,12 +78,20 @@ public class BaseRestClient {
protected ClientResponse jsonPUT(WebResource resource, String body) {
return requestPUT(resource, body, MediaType.APPLICATION_JSON);
}
protected ClientResponse requestPOST(WebResource resource, String params, String type) {
protected ClientResponse requestPOST(WebResource resource, String body) {
if (!isLoggedIn()) {
log.info("User is not loggedin");
try {
createSession();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
WebResource.Builder builder = decorateBuilder(resource);
return builder.type(type).post(ClientResponse.class, params);
return builder.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, body);
}
// -------------------------------------------- Login --------------------------------------------------------------
......
......@@ -3,11 +3,15 @@ package rest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.jersey.api.client.ClientResponse;
import ddsl.enums.ResourceTypes;
import org.json.JSONObject;
import rest.models.DomainModel;
import rest.models.MemberModel;
import utils.TestRunData;
import java.util.ArrayList;
import java.util.List;
public class DomainClient extends BaseRestClient {
/**
......@@ -70,4 +74,31 @@ public class DomainClient extends BaseRestClient {
return response.getEntity(MemberModel.class);
}
public DomainModel addResourcesToDomain(String domainId, List<ResourceTypes> resourceTypesList) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
List<String> resourceListToBeAdded = new ArrayList<>();
for (ResourceTypes resourceType : resourceTypesList) {
resourceListToBeAdded.add(resourceType.getName());
}
String resourceTypes = mapper.writeValueAsString(resourceListToBeAdded);
if (!isLoggedIn()) {
try {
createSession();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
String addMemberPath = RestServicePaths.getAddResourcePath(TestRunData.getInstance().getUserId(), resourceTypes);
ClientResponse response = requestPOST(resource.path(addMemberPath), resourceTypes);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not add resource!", response);
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
}
log.debug("Resources have been added!");
return response.getEntity(DomainModel.class);
}
}
......@@ -29,5 +29,9 @@ public class RestServicePaths {
return "/edit/rest/" + currentUserId + "/domain/" + domainId + "/member/put";
}
public static String getAddResourcePath(String currentUserId, String domainId) {
return String.format("/internal/rest/domain/%userId/%domainId/update-resource-types", currentUserId, domainId);
}
}
package rest.models;
import utils.Generator;
public class GroupModel {
private String groupName;
private String visibility;
private String groupDescription;
public static GroupModel generatePublicDomain() {
GroupModel groupModel = new GroupModel();
groupModel.groupName = ("AUT_groupName_" + Generator.randomAlphaNumeric(4)).toLowerCase();
groupModel.groupDescription = Generator.randomAlphaNumeric(10).toLowerCase();
groupModel.visibility = "PUBLIC";
return groupModel;
}
public static GroupModel generatePrivateDomain() {
GroupModel groupModel = new GroupModel();
groupModel.groupName = ("AUT_groupName_" + Generator.randomAlphaNumeric(4)).toLowerCase();
groupModel.groupDescription = Generator.randomAlphaNumeric(10).toLowerCase();
groupModel.visibility = "PRIVATE";
return groupModel;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getVisibility() {
return visibility;
}
public void setVisibility(String visibility) {
this.visibility = visibility;
}
public String getGroupDescription() {
return groupDescription;
}
public void setGroupDescription(String groupDescription) {
this.groupDescription = groupDescription;
}
}
# Environment properties
# Test runner properties
test.webdriver.path=./chromedriver.exe
test.webdriver.type=chrome
#test.webdriver.path=./geckodriver.exe
#test.webdriver.type=firefox
#test.webdriver.path=./chromedriver.exe
#test.webdriver.type=chrome
test.webdriver.path=./geckodriver.exe
test.webdriver.type=firefox
test.webdriver.headless=false
test.application.ui.url=http://eulogin.protected.smp.local:8982/smp/ui
......
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