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 9fa10d30 authored by Mihai BOZ's avatar Mihai BOZ
Browse files

Merge branch 'development' into EDELIVERY-12247-Automate_new_SMP_UI_testcases-part_4

# Conflicts:
#	domiSMP-ui-tests/src/main/java/ddsl/CommonCertificatePage.java
parents 2ae6885e b3285d97
No related branches found
No related tags found
No related merge requests found
Showing
with 117 additions and 280 deletions
......@@ -7,10 +7,11 @@ 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;
......@@ -24,6 +25,7 @@ public class CommonPageWithTabs extends DomiSMPPage {
element.click();
wait.forAttributeToContain(element, "aria-selected", "true");
LOG.debug("Domain tab {} is opened", tabName);
break;
}
}
}
......
......@@ -8,14 +8,11 @@ import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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);
/**
* 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;
@FindBy(css = "data-panel >div >div> mat-toolbar button:first-of-type")
......@@ -26,6 +23,7 @@ public class CommonPageWithTabsAndGrid extends CommonPageWithTabs {
public CommonPageWithTabsAndGrid(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
LOG.debug("CommonPageWithTabs is loaded");
}
public SmallGrid getLeftSideGrid() {
......
......@@ -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();
......
......@@ -21,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;
......
......@@ -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);
......
......@@ -3,13 +3,18 @@ package ddsl.dcomponents.commonComponents.subcategoryTab;
import ddsl.dcomponents.ConfirmationDialog;
import ddsl.dcomponents.DComponent;
import ddsl.dcomponents.Grid.SmallGrid;
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")
......@@ -31,7 +36,7 @@ public class SubcategoryTabComponent extends DComponent {
return new SmallGrid(driver, rightSidePanel);
}
public void create() throws Exception {
public void create() throws ElementNotInteractableException {
weToDButton(createBtn).click();
}
......@@ -42,7 +47,7 @@ public class SubcategoryTabComponent extends DComponent {
weToDButton(editBtn).click();
}
protected void delete(String columnName, String value) throws Exception {
protected void delete(String columnName, String value){
WebElement tobeDeleted = getGrid().searchAndGetElementInColumn(columnName, value);
tobeDeleted.click();
wait.forElementToBeEnabled(deleteBtn);
......
......@@ -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 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.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;
......
......@@ -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")
......
......@@ -8,7 +8,9 @@ import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import rest.models.GroupModel;
/**
* Page object create new group dialog of Edit Groups page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class CreateGroupDetailsDialog extends DComponent {
@FindBy(id = "name_id")
private WebElement groupNameLbl;
......@@ -18,15 +20,26 @@ public class CreateGroupDetailsDialog extends DComponent {
private WebElement groupVisibilityDdl;
@FindBy(id = "saveButton")
private WebElement saveBtn;
private AlertComponent alertComponent = null;
public CreateGroupDetailsDialog(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
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 void fillGroupDetails(GroupModel group) {
......@@ -35,7 +48,7 @@ public class CreateGroupDetailsDialog extends DComponent {
weToDSelect(groupVisibilityDdl).selectValue(group.getVisibility());
}
public Boolean tryClickOnSave() throws Exception {
public Boolean tryClickOnSave(){
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
......
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