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 08709326 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Merge pull request #160 in EDELIVERY/smp from selImprov to development

* commit '4fb16218d7163780facb6ea10f6d8db556cdd7a3':
  stability improvements
parents aa33c2fb 8d251e29
No related branches found
No related tags found
No related merge requests found
Showing with 180 additions and 106 deletions
......@@ -19,4 +19,5 @@
.idea/**
.target/**
target/**
.\src\main\java\Main.java
\ No newline at end of file
......@@ -54,10 +54,35 @@ public class PageComponent {
}
}
// public void waitForElementToBeGone(WebElement element) {
// try {
// webDriverWait.until(ExpectedConditions.not(ExpectedConditions.visibilityOf(element)));
// } catch (Exception e) { }
// }
public void waitForElementToBeGone(WebElement element) {
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
try {
webDriverWait.until(ExpectedConditions.not(ExpectedConditions.visibilityOf(element)));
} catch (Exception e) { }
myWait.until(ExpectedConditions.visibilityOf(element));
} catch (Exception e) { return;}
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime >0){
boolean displayed = true;
try {
displayed = element.isDisplayed();
} catch (Exception e) {
return;
}
if(!displayed){
return;
}
waitForXMillis(500);
waitTime = waitTime - 500;
}
}
public void waitForNumberOfWindowsToBe(int noOfWindows) {
......
......@@ -16,27 +16,14 @@ public class SMPPage extends PageComponent {
public Header pageHeader = new Header(driver);
public void refreshPage(){
public void refreshPage() {
driver.navigate().refresh();
try {
new SMPPage(driver).pageHeader.waitForTitleToBe();
} catch (Exception e) {
e.printStackTrace();
}
}
public void screenshotPage(){
// try {
// File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
//
// OutputStream out = new FileOutputStream(new File("screenshot.png"));
//
//
//
// scrFile.createNewFile();
// out.write(scrFile);
// out.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
}
}
......@@ -4,6 +4,7 @@ package utils;
public class PROPERTIES {
public static final String UI_BASE_URL = System.getProperty("UI_BASE_URL");
public static final int SHORT_UI_TIMEOUT = 5;
public static final int TIMEOUT = Integer.valueOf(System.getProperty("SHORT_TIMEOUT"));
public static final int LONG_WAIT = Integer.valueOf(System.getProperty("LONG_TIMEOUT"));
public static final String REPORTS_FOLDER = System.getProperty("reports.folder");
......
......@@ -12,6 +12,7 @@ import utils.customReporter.ExcelTestReporter;
import utils.customReporter.TestProgressReporter;
import utils.rest.SMPRestClient;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -20,6 +21,8 @@ import java.util.List;
@Listeners({ExcelTestReporter.class, TestProgressReporter.class})
public class BaseTest {
static int methodCount = 1;
static WebDriver driver;
protected Logger logger = Logger.getLogger(this.getClass());
static TestDataProvider testDataProvider = new TestDataProvider();
......@@ -28,7 +31,7 @@ public class BaseTest {
static ArrayList<String> createdUsers = new ArrayList<>();
static ArrayList<String> createdServiceGroups = new ArrayList<>();
protected Logger log = Logger.getLogger(this.getClass());
@BeforeSuite(alwaysRun = true)
/*Starts the browser and navigates to the homepage. This happens once before the test
......@@ -80,6 +83,13 @@ public class BaseTest {
driver.get(PROPERTIES.UI_BASE_URL);
}
@BeforeMethod(alwaysRun = true)
protected void logSeparator(Method method) throws Exception {
log.info("--------------------------- Running test number: " + methodCount);
log.info("--------------------------- Running test method: " + method.getDeclaringClass().getSimpleName() + "." + method.getName());
methodCount++;
}
private void createDomains(){
......@@ -125,13 +135,25 @@ public class BaseTest {
private void deleteTestData(){
for (String createdServiceGroup : createdServiceGroups) {
SMPRestClient.deleteSG(createdServiceGroup);
try {
SMPRestClient.deleteSG(createdServiceGroup);
} catch (Exception e) {
e.printStackTrace();
}
}
for (String createdUser : createdUsers) {
SMPRestClient.deleteUser(createdUser);
try {
SMPRestClient.deleteUser(createdUser);
} catch (Exception e) {
e.printStackTrace();
}
}
for (String createdDomain : createdDomains) {
SMPRestClient.deleteDomain(createdDomain);
try {
SMPRestClient.deleteDomain(createdDomain);
} catch (Exception e) {
e.printStackTrace();
}
}
}
......
......@@ -59,7 +59,6 @@ public class DomainPgTest extends BaseTest {
DomainPopup popup = new DomainPopup(driver);
page.screenshotPage();
soft.assertTrue(popup.isLoaded(), "Domain popup is loaded");
soft.assertTrue(!popup.isDomainCodeInputEnabled(), "On double click Domain Code input is disabled");
......
......@@ -85,7 +85,6 @@ public class EditPgTest extends BaseTest {
public void doubleclickRow() {
String extensionData = "<Extension xmlns=\"http://docs.oasis-open.org/bdxr/ns/SMP/2016/05\"><ExtensionID>df</ExtensionID><ExtensionName>sdxf</ExtensionName><!-- Custom element is mandatory by OASIS SMP schema. Replace following element with your XML structure. --><ext:example xmlns:ext=\"http://my.namespace.eu\">" + Generator.randomAlphaNumeric(10) + "</ext:example></Extension>";
SoftAssert soft = new SoftAssert();
EditPage page = new EditPage(driver);
......
package ui;
import org.openqa.selenium.JavascriptExecutor;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
......@@ -8,31 +9,47 @@ import pages.components.messageArea.AlertMessage;
import pages.service_groups.search.SearchPage;
import pages.components.baseComponents.SMPPage;
import pages.login.LoginPage;
import utils.Generator;
import utils.enums.SMPMessages;
import utils.rest.SMPRestClient;
import java.util.HashMap;
public class LoginPgTest extends BaseTest {
@AfterMethod
public void logoutAndReset(){
public void logoutAndReset() {
log.info("deleting cookies");
driver.manage().deleteAllCookies();
try {
log.info("clearing localstorage");
((JavascriptExecutor) driver).executeScript("localStorage.clear();");
} catch (Exception e) {
log.info("clearing localcstorage failed");
}
SMPPage page = new SMPPage(driver);
log.info("refreshing page to close all popups");
page.refreshPage();
if(page.pageHeader.sandwichMenu.isLoggedIn()){
logger.info("Logout!!");
page.pageHeader.sandwichMenu.logout();
try {
if (page.pageHeader.sandwichMenu.isLoggedIn()) {
logger.info("Logout!!");
page.pageHeader.sandwichMenu.logout();
}
logger.info("Going to Search page");
page.sidebar.goToPage(SearchPage.class);
} catch (Exception e) {
e.printStackTrace();
}
logger.info("Going to Search page");
page.sidebar.goToPage(SearchPage.class);
}
@Test(description = "LGN-0")
public void loginPageNavigation(){
public void loginPageNavigation() {
SoftAssert soft = new SoftAssert();
......@@ -49,7 +66,7 @@ public class LoginPgTest extends BaseTest {
@Test(description = "LGN-10")
public void loginPageBuildNumberTest(){
public void loginPageBuildNumberTest() {
SoftAssert soft = new SoftAssert();
SearchPage page = new SearchPage(driver);
......@@ -64,10 +81,8 @@ public class LoginPgTest extends BaseTest {
}
@Test(description = "LGN-20")
public void loginPageDisplayTest(){
public void loginPageDisplayTest() {
SoftAssert soft = new SoftAssert();
SearchPage page = new SearchPage(driver);
......@@ -92,29 +107,31 @@ public class LoginPgTest extends BaseTest {
}
@Test(description = "LGN-30")
public void successfulLogin(){
public void successfulLogin() {
SoftAssert soft = new SoftAssert();
String username = Generator.randomAlphaNumeric(10);
SMPRestClient.createUser(username, "SYSTEM_ADMIN");
log.info("created user " + username);
SMPPage page = new SMPPage(driver);
logger.info("Going to login page");
page.pageHeader.goToLogin();
log.info("trying to login with " + username);
LoginPage loginPage = new LoginPage(driver);
HashMap<String, String> user = testDataProvider.getUserWithRole("SYS_ADMIN");
SearchPage searchPage = loginPage.login(user.get("username"), user.get("password"));
SearchPage searchPage = loginPage.login(username, "QW!@qw12");
soft.assertTrue(searchPage.pageHeader.sandwichMenu.isLoggedIn(), "User is logged in");
soft.assertTrue(searchPage.isLoaded(), "Search page is loaded");
soft.assertAll();
}
// Tests that using invalid credentials leads to proper error message
// Tests that using invalid credentials leads to proper error message
@Test(description = "LGN-40")
public void unsuccessfulLogin(){
public void unsuccessfulLogin() {
SoftAssert soft = new SoftAssert();
SMPPage page = new SMPPage(driver);
......@@ -140,14 +157,11 @@ public class LoginPgTest extends BaseTest {
soft.assertAll();
}
// This will serve as a reminder to check this message manually
// This will serve as a reminder to check this message manually
@Test(description = "LGN-50")
public void SMPNotRunningTest(){
public void SMPNotRunningTest() {
throw new SkipException("This test will be executed manually !!!");
}
}
......@@ -23,9 +23,13 @@ public class PrivilegesTests extends BaseTest {
SMPPage page = new SMPPage(driver);
page.refreshPage();
if(page.pageHeader.sandwichMenu.isLoggedIn()){
logger.info("Logout!!");
page.pageHeader.sandwichMenu.logout();
try {
if(page.pageHeader.sandwichMenu.isLoggedIn()){
logger.info("Logout!!");
page.pageHeader.sandwichMenu.logout();
}
} catch (Exception e) {
e.printStackTrace();
}
}
......
......@@ -311,20 +311,22 @@ public class SearchPgTest extends BaseTest {
SMPRestClient.createServiceGroup(participantID, participantScheme, owners, domains);
SearchPage searchPage = new SearchPage(driver);
searchPage.refreshPage();
searchPage.filters.filter(participantID, participantScheme, SMPRestClient.getDomainSubDomainCombo(createdDomains.get(0)));
List<ServiceGroupRow> results = searchPage.serviceGroupGrid.getRows();
soft.assertTrue(results.size() == 1, "Results size is 1 (first search)");
soft.assertTrue(results.get(0).getParticipantIdentifier().equalsIgnoreCase(participantID),
// soft.assertTrue(results.size() == 1, "Results size is 1 (first search)");
soft.assertEquals(results.size() , 1, "Results size is 1 (first search)");
soft.assertEquals(results.get(0).getParticipantIdentifier().toLowerCase(), participantID.toLowerCase(),
"First and only result is the one we entered and is found when filtering by first domain");
searchPage.filters.filter(participantID, participantScheme, SMPRestClient.getDomainSubDomainCombo(createdDomains.get(1)));
results = searchPage.serviceGroupGrid.getRows();
soft.assertTrue(results.size() == 1, "Results size is 1 (second search)");
soft.assertTrue(results.get(0).getParticipantIdentifier().equalsIgnoreCase(participantID),
soft.assertEquals(results.size(), 1, "Results size is 1 (second search)");
soft.assertEquals(results.get(0).getParticipantIdentifier().toLowerCase(), participantID.toLowerCase(),
"First and only result is the one we entered and is found when filtering by second domain");
......
......@@ -20,55 +20,55 @@ import java.util.Arrays;
import java.util.List;
public class UsersPgTest extends BaseTest {
@AfterMethod
public void logoutAndReset(){
public void logoutAndReset() {
SMPPage page = new SMPPage(driver);
page.refreshPage();
if(page.pageHeader.sandwichMenu.isLoggedIn()){
if (page.pageHeader.sandwichMenu.isLoggedIn()) {
logger.info("Logout!!");
page.pageHeader.sandwichMenu.logout();
}
}
@BeforeMethod
public void loginAndGoToUsersPage(){
public void loginAndGoToUsersPage() {
SMPPage page = new SMPPage(driver);
if(page.pageHeader.sandwichMenu.isLoggedIn()){
if (page.pageHeader.sandwichMenu.isLoggedIn()) {
logger.info("Logout!!");
page.pageHeader.sandwichMenu.logout();
}
if(!page.pageHeader.sandwichMenu.isLoggedIn()){
if (!page.pageHeader.sandwichMenu.isLoggedIn()) {
logger.info("Login!!");
page.pageHeader.goToLogin().login("SYS_ADMIN");
}
logger.info("Going to Users page");
page.sidebar.goToPage(UsersPage.class);
}
@Test(description = "USR-10")
public void newUser(){
public void newUser() {
String username = Generator.randomAlphaNumeric(10);
String validPass = "QW!@qw12";
SoftAssert soft = new SoftAssert();
UsersPage usersPage = new UsersPage(driver);
// soft.assertTrue(usersPage.isNewButtonEnabled(), "New button should be enabled");
UserPopup popup = usersPage.clickNew();
soft.assertTrue(!popup.isOKButtonActive(), "OK button should be disabled until valid data is filled in the popup");
popup.rolesSelect.selectOptionWithText("SYSTEM_ADMIN");
popup.clickUserDetailsToggle();
popup.fillDetailsForm(username, validPass, validPass);
......@@ -89,7 +89,7 @@ public class UsersPgTest extends BaseTest {
@Test(description = "USR-20")
public void usernameValidation(){
public void usernameValidation() {
String username = Generator.randomAlphaNumeric(10);
String validPass = "QW!@qw12";
......@@ -120,7 +120,7 @@ public class UsersPgTest extends BaseTest {
@SuppressWarnings("SpellCheckingInspection")
@Test(description = "USR-30")
public void passwordValidation(){
public void passwordValidation() {
ArrayList<String> passToValidate = new ArrayList<>(Arrays.asList("qwqw",
"QWERQWERQWERQWERQWERQWERQWERQWE33",
......@@ -152,7 +152,7 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-40")
public void listedRoles(){
public void listedRoles() {
ArrayList<String> expectedRoleValues = new ArrayList<>(Arrays.asList("SYSTEM_ADMIN", "SMP_ADMIN", "SERVICE_GROUP_ADMIN"));
......@@ -167,7 +167,7 @@ public class UsersPgTest extends BaseTest {
for (String expected : expectedRoleValues) {
boolean found = false;
for (String listedRole : listedRoles) {
if(listedRole.equalsIgnoreCase(expected)){
if (listedRole.equalsIgnoreCase(expected)) {
found = true;
}
}
......@@ -178,13 +178,16 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-50")
public void deleteSYS_ADMIN(){
public void deleteSYS_ADMIN() {
String username = Generator.randomAlphaNumeric(10);
SMPRestClient.createUser(username, "SYSTEM_ADMIN");
SoftAssert soft = new SoftAssert();
log.info("created user " + username);
UsersPage page = new UsersPage(driver);
page.refreshPage();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
......@@ -219,7 +222,7 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-60")
public void changeRoleSYS_ADMIN(){
public void changeRoleSYS_ADMIN() {
SoftAssert soft = new SoftAssert();
......@@ -236,7 +239,7 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-70")
public void changeRoleNON_SYS_ADMIN(){
public void changeRoleNON_SYS_ADMIN() {
SoftAssert soft = new SoftAssert();
......@@ -255,7 +258,7 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-80")
public void deleteOWNUserRecord(){
public void deleteOWNUserRecord() {
String username = new TestDataProvider().getUserWithRole("SYS_ADMIN").get("username");
......@@ -277,13 +280,17 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-90")
public void deleteSMP_ADMIN(){
public void deleteSMP_ADMIN() {
String username = Generator.randomAlphaNumeric(10);
SMPRestClient.createUser(username, "SMP_ADMIN");
SoftAssert soft = new SoftAssert();
log.info("Created username " + username);
UsersPage page = new UsersPage(driver);
page.refreshPage();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
......@@ -319,13 +326,15 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-100")
public void deleteSERVICE_GROUP_ADMIN(){
public void deleteSERVICE_GROUP_ADMIN() {
String username = Generator.randomAlphaNumeric(10);
SMPRestClient.createUser(username, "SERVICE_GROUP_ADMIN");
log.info("Created username" + username);
SoftAssert soft = new SoftAssert();
UsersPage page = new UsersPage(driver);
page.refreshPage();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
......@@ -360,7 +369,7 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-110")
public void deleteSG_ADMINWithSG(){
public void deleteSG_ADMINWithSG() {
String username = Generator.randomAlphaNumeric(10);
String pi = Generator.randomAlphaNumeric(10);
......@@ -374,9 +383,13 @@ public class UsersPgTest extends BaseTest {
new ArrayList<>(Arrays.asList(createdDomains.get(0)))
);
log.info("Created username " + username);
log.info("Created service group " + pi);
SoftAssert soft = new SoftAssert();
UsersPage page = new UsersPage(driver);
page.refreshPage();
int index = scrollToUser(username);
page.grid().selectRow(index);
......@@ -394,7 +407,7 @@ public class UsersPgTest extends BaseTest {
}
@Test(description = "USR-120")
public void deleteSMP_ADMINWithSG(){
public void deleteSMP_ADMINWithSG() {
String username = Generator.randomAlphaNumeric(10);
String pi = Generator.randomAlphaNumeric(10);
......@@ -408,9 +421,12 @@ public class UsersPgTest extends BaseTest {
new ArrayList<>(Arrays.asList(createdDomains.get(0)))
);
log.info("Created username "+ username);
SoftAssert soft = new SoftAssert();
UsersPage page = new UsersPage(driver);
page.refreshPage();
int index = scrollToUser(username);
page.grid().selectRow(index);
......@@ -429,9 +445,7 @@ public class UsersPgTest extends BaseTest {
}
private boolean isUserListed(String username){
private boolean isUserListed(String username) {
boolean end = false;
UsersPage page = new UsersPage(driver);
......@@ -442,20 +456,23 @@ public class UsersPgTest extends BaseTest {
List<UserRowInfo> rows = page.grid().getRows();
for (UserRowInfo row : rows) {
if(row.getUsername().equalsIgnoreCase(username)){
if (row.getUsername().equalsIgnoreCase(username)) {
return true;
}
}
if(page.pagination.hasNextPage()){
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
}else{end = true;}
} else {
end = true;
}
}
return false;
}
private int scrollToUser(String username){
private int scrollToUser(String username) {
UsersPage page = new UsersPage(driver);
page.pagination.skipToFirstPage();
......@@ -465,20 +482,22 @@ public class UsersPgTest extends BaseTest {
List<UserRowInfo> rows = page.grid().getRows();
for (int i = 0; i < rows.size(); i++) {
if(rows.get(i).getUsername().equalsIgnoreCase(username)){
if (rows.get(i).getUsername().equalsIgnoreCase(username)) {
return i;
}
}
if(page.pagination.hasNextPage()){
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
}else{end = true;}
} else {
end = true;
}
}
return -1;
}
private int scrollToUserWithRole(String role){
private int scrollToUserWithRole(String role) {
UsersPage page = new UsersPage(driver);
page.pagination.skipToFirstPage();
......@@ -488,19 +507,20 @@ public class UsersPgTest extends BaseTest {
List<UserRowInfo> rows = page.grid().getRows();
for (int i = 0; i < rows.size(); i++) {
if(rows.get(i).getRole().equalsIgnoreCase(role)){
if (rows.get(i).getRole().equalsIgnoreCase(role)) {
return i;
}
}
if(page.pagination.hasNextPage()){
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
}else{end = true;}
} else {
end = true;
}
}
return -1;
}
}
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