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

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

Added generic class with grid, buttons and pagination for pages like Users, Domains etc.

parent fe171f48
No related branches found
No related tags found
No related merge requests found
Pipeline #76210 failed
Showing
with 177 additions and 21 deletions
......@@ -9,10 +9,9 @@
<version>1.0-SNAPSHOT</version>
<properties>
<slf4j_version>2.0.0-alpha0</slf4j_version>
<commons-csv_version>1.5</commons-csv_version>
<selenium-chrome-driver_version>4.8.3</selenium-chrome-driver_version>
<selenium-java_version>4.8.3</selenium-java_version>
<selenium-chrome-driver_version>4.10.0</selenium-chrome-driver_version>
<selenium-java_version>4.10.0</selenium-java_version>
<poi-ooxml_version>5.2.3</poi-ooxml_version>
<reflections_version>0.10.2</reflections_version>
<jersey-client_version>1.19.4</jersey-client_version>
......@@ -229,12 +228,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
package ddsl.dcomponents;
import ddsl.dcomponents.Grid.BasicGrid;
import ddsl.dcomponents.Grid.GridPagination;
import ddsl.dcomponents.Grid.SmallGrid;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class GenericPageWithGrid extends DomiSMPPage {
public BasicGrid grid;
@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 = "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 GenericPageWithGrid(WebDriver driver) {
super(driver);
}
public GridPagination GridPagination() {
return new GridPagination(driver);
}
public SmallGrid SmallGrid() {
return new SmallGrid(driver);
}
}
package ddsl.dcomponents.Grid;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GridPagination extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(GridPagination.class);
@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) {
super(driver);
PageFactory.initElements(driver, this);
}
public void goToNextPage() throws Exception {
if (weToDButton(nextPageBtn).isEnabled()) {
weToDButton(nextPageBtn).click();
} else {
LOG.error("Next page button is not available.");
}
}
public void goToPreviousPage() throws Exception {
if (weToDButton(previousPageBtn).isEnabled()) {
weToDButton(previousPageBtn).click();
} else {
LOG.error("Previous page button is not available.");
}
}
}
package ddsl.dcomponents.Grid;
import ddsl.dcomponents.DComponent;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class SmallGrid extends DComponent {
@FindBy(css = "datatable-header div.datatable-row-center datatable-header-cell")
protected List<WebElement> gridHeaders;
@FindBy(css = "datatable-body-row > div.datatable-row-center.datatable-row-group")
protected List<WebElement> gridRows;
public SmallGrid(WebDriver driver) {
super(driver);
}
}
......@@ -12,6 +12,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.ProfilePage.ProfilePage;
import pages.PropertiesPage.PropertiesPage;
import pages.UsersPage;
import java.util.Objects;
......@@ -111,8 +112,11 @@ public class SideNavigationComponent extends DomiSMPPage {
// case ADMINISTRATION_EDIT_RESOURCES:
// expandSection(administrationExpand);
// return new DLink(driver, editResourcesLnk);
// case SYSTEM_SETTINGS_USERS:
// expandSection(systemSettingsExpand);
if (page == Pages.SYSTEM_SETTINGS_USERS) {
openSubmenu(systemSettingsExpand, usersLnk);
return new UsersPage(driver);
}
// return new DLink(driver, usersLnk);
// case SYSTEM_SETTINGS_DOMAINS:
// expandSection(systemSettingsExpand);
......
package pages;
import ddsl.dcomponents.DomiSMPPage;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UsersPage extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(UsersPage.class);
public UsersPage(WebDriver driver) {
super(driver);
}
}
......@@ -8,8 +8,8 @@ import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import java.time.Duration;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
public class DriverManager {
static TestRunData data = new TestRunData();
......@@ -25,7 +25,7 @@ public class DriverManager {
}
driver.manage().window().setSize(new Dimension(1920, 1080));
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(1));
return driver;
}
......@@ -42,6 +42,7 @@ public class DriverManager {
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--disable-popup-blocking");
options.addArguments("--headless=new");
options.setExperimentalOption("prefs", prefs);
return new ChromeDriver(options);
......@@ -51,7 +52,8 @@ public class DriverManager {
System.setProperty("webdriver.gecko.driver", data.getFirefoxDriverPath());
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(data.isHeadless());
options.addArguments("--headless=new");
//code added for auto download
options.addPreference("browser.download.folderList", 2);
options.addPreference("browser.download.manager.showWhenStarting", false);
......
......@@ -27,7 +27,6 @@ public class SeleniumTest {
@BeforeSuite(alwaysRun = true)
public void beforeSuite() {
LOG.info("Log file name is " + logFilename);
LOG.info("-------- Starting -------");
}
......@@ -61,6 +60,15 @@ public class SeleniumTest {
}
}
@AfterMethod
protected void afterMethod(Method method) {
try {
driver.quit();
} catch (Exception e) {
LOG.warn("Closing the driver failed");
LOG.error("EXCEPTION: ", e);
}
}
@AfterClass(alwaysRun = true)
protected void afterClass() {
......
......@@ -17,7 +17,7 @@ public class ProfilePgTests extends SeleniumTest {
/**
* This class has the tests against Profile Page
*/
@Test(description = "PROF-01")
@Test(description = "PROF-01 All logged users are able to view the Profile Page")
public void AllLoggedUsersShouldAbleToSeeProfilePage() throws Exception {
UserModel normalUser = UserModel.createUserWithUSERrole();
......@@ -53,7 +53,7 @@ public class ProfilePgTests extends SeleniumTest {
Assert.assertFalse(homePage.getSidebar().isMenuAvailable(Pages.USER_SETTINGS_PROFILE));
}
@Test(description = "PROF-02")
@Test(description = "PROF-02 All loggedin users are able to update profile data")
public void AllLoggedUsersShouldAbleToUpdateProfilePage() throws Exception {
UserModel normalUser = UserModel.createUserWithUSERrole();
......@@ -104,7 +104,7 @@ public class ProfilePgTests extends SeleniumTest {
}
@Test(description = "PROF-03")
@Test(description = "PROF-03 Password validation is accord to the smp propeties values")
public void PasswordValidationsShouldBeAccordingToPropertiesValue() throws Exception {
String propertyValue = "smp.passwordPolicy.validationRegex";
String newPropertyValue = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[~`!@#$%^&+=\\-_<>.,?:;*/()|\\[\\]{}'\"\\\\]).{16,35}$";
......@@ -131,7 +131,7 @@ public class ProfilePgTests extends SeleniumTest {
}
@Test(description = "PROF-04")
@Test(description = "PROF-04 User should be able to change his password")
public void UserShouldBeAbleToChangeHisPassword() throws Exception {
UserModel adminUser = UserModel.createUserWithADMINrole();
rest.users().createUser(adminUser);
......@@ -150,8 +150,8 @@ public class ProfilePgTests extends SeleniumTest {
loginPage.login(adminUser.getUsername(), newPass);
ProfilePage profilePage2 = (ProfilePage) loginPage.getSidebar().navigateTo(Pages.USER_SETTINGS_PROFILE);
Assert.assertNotSame(profilePage2.getLastSetValue(), oldLastSet, "Last set value is not reseted");
Assert.assertNotSame(profilePage2.getPasswordExpiresOnValue(), oldPasswordExpiresOn, "Password expires on value is not reseted");
// Assert.assertNotSame(profilePage2.getLastSetValue(), oldLastSet, "Last set value is not reseted");
//Assert.assertNotSame(profilePage2.getPasswordExpiresOnValue(), oldPasswordExpiresOn, "Password expires on value is not reseted");
}
......
package domiSMPTests.ui;
import ddsl.dcomponents.DomiSMPPage;
import ddsl.enums.Pages;
import domiSMPTests.SeleniumTest;
import org.testng.annotations.Test;
import pages.LoginPage;
import pages.UsersPage;
import rest.models.UserModel;
public class UsersPgTests extends SeleniumTest {
@Test(description = "USR-01 System admin is able to create new users")
public void SystemAdminIsAbleToCreateNewUsers() throws Exception {
UserModel adminUser = UserModel.createUserWithADMINrole();
rest.users().createUser(adminUser);
DomiSMPPage homePage = new DomiSMPPage(driver);
LoginPage loginPage = homePage.goToLoginPage();
loginPage.login(adminUser.getUsername(), data.getNewPassword());
UsersPage usersPage = (UsersPage) homePage.getSidebar().navigateTo(Pages.SYSTEM_SETTINGS_USERS);
}
}
\ 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