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

Skip to content
Snippets Groups Projects
Commit 69771a55 authored by Sonali MOHANTY's avatar Sonali MOHANTY Committed by Catalin COMANICI
Browse files

Pull request #174: 1)Duplicate domain code validation in domain pop up page

Merge in EDELIVERY/smp from smpAutomation to development

* commit 'fd9b91ce588c8de7fda43606ade07963ed4b4e94':
  minor changes
  Changes are made according to the comment provided in pull request 174.
  1)Duplicate domain code validation in domain pop up page 2)domain code is showing as strikethrough in domain grid page when only domain code is used to create new domain 3)Error message is showing while creating duplicate user 4)Error message is showing when password and confirm password doesn't match in user pop up page
  1)Duplicate domain code validation in domain pop up page 2)domain code is showing as strikethrough in domain grid page when only domain code is used to create new domain 3)Error message is showing while creating duplicate user 4)Error message is showing when password and confirm password doesn't match in user pop up page
parents 8d3415ff c9dc4050
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<url>http://localhost:57005/smp</url>
<url>http://localhost:8080/smp-4.1.1</url>
<gecko.driver.path>drivers/geckodriver.exe</gecko.driver.path>
<chrome.driver.path>drivers/chromedriver.exe</chrome.driver.path>
</properties>
......
......@@ -75,9 +75,10 @@ public class BasicGrid extends PageComponent {
public int getRowsNo(){
return gridRows.size();
}
public void scrollRow(int index) {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].scrollIntoView();",gridRows.get(index));
waitForXMillis(500);
}
}
......@@ -3,6 +3,7 @@ package pages.domain;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import pages.components.grid.BasicGrid;
import java.util.ArrayList;
......@@ -48,5 +49,80 @@ public class DomainGrid extends BasicGrid {
return rowInfos;
}
public void mouseHoverOnDomainCode(int rowNumber) {
WebElement element = driver.findElement(By.cssSelector(".datatable-row-wrapper:nth-child(" + rowNumber + ") .datatable-body-cell:nth-child(1) .datatable-body-cell-label span"));
Actions action = new Actions(driver);
action.moveToElement(element).build().perform();
}
public boolean isDomainStillPresent(String domainCode) {
boolean end = false;
List<DomainRow> rows = new ArrayList<>();
DomainPage page = new DomainPage(driver);
page.pagination.skipToFirstPage();
while (!end) {
rows.addAll(page.grid().getRowsInfo());
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
} else {
end = true;
}
}
boolean found = false;
for (DomainRow row : rows) {
if (row.getDomainCode().equalsIgnoreCase(domainCode)) {
found = true;
}
}
return found;
}
public int scrollToDomain(String domainCode) {
DomainPage page = new DomainPage(driver);
page.pagination.skipToFirstPage();
boolean end = false;
while (!end) {
List<DomainRow> rows = page.grid().getRowsInfo();
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).getDomainCode().equalsIgnoreCase(domainCode)) {
return i;
}
}
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
} else {
end = true;
}
}
return -1;
}
public int scrollToSmlDomain(String smlDomain) {
try {
DomainPage page = new DomainPage(driver);
List<DomainRow> rows;
int count = 0;
do {
if (count != 0) {
page.pagination.goToNextPage();
}
rows = page.grid().getRowsInfo();
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).getSmlDomain().equalsIgnoreCase(smlDomain)) {
return i;
}
}
count++;
}
while (page.pagination.hasNextPage());
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
}
......@@ -8,8 +8,6 @@ import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.components.ConfirmationDialog;
import pages.components.baseComponents.PaginationControls;
import pages.components.baseComponents.SMPPage;
import pages.components.grid.BasicGrid;
import pages.users.UserPopup;
import utils.PROPERTIES;
public class DomainPage extends SMPPage {
......
package pages.domain;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -87,6 +88,41 @@ public class DomainPopup extends PageComponent {
smlClientAliasSelect.selectFirstOption();
}
public String getDuplicateDomainErrorMsgText()
{
WebElement duplicateDomainErrorMsg = driver.findElement(By.cssSelector(".mat-form-field-infix > div.ng-star-inserted"));
return duplicateDomainErrorMsg.getText();
}
public boolean isEnableOkButton()
{
try {
return okBtn.isEnabled();
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}
public boolean isEnableCancelButton()
{
try {
return cancelBtn.isEnabled();
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}
public void clearAndFillDomainCodeInput(String domainCode) {
log.info("filling only domain code data for new domain");
clearAndFillInput(domainCodeInput, domainCode);
}
}
package pages.users;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -43,6 +44,9 @@ public class UserPopup extends PageComponent {
@FindBy(css = "mat-form-field.password-confirmation > div > div.mat-form-field-flex > div > div")
WebElement passConfirmationValidationError;
@FindBy(css = ".mat-form-field-infix > div.has-error")
WebElement passMatchValidationError;
@FindBy(css = "mat-dialog-content > table > tbody > tr > td > button:nth-child(1)")
WebElement okBtn;
......@@ -129,4 +133,18 @@ public class UserPopup extends PageComponent {
}
return null;
}
public boolean isDuplicateUserNameErrorMsgDisPlayed() {
try {
return driver.findElement(By.cssSelector("mat-form-field.username > div .has-error")).isDisplayed();
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public String getPassDontMatchValidationMsg() {
// WebElement passwordUnmatchingMsg = driver.findElement(By.cssSelector(".mat-form-field-infix > div.has-error"));
return passMatchValidationError.getText();
}
}
......@@ -3,6 +3,7 @@ package pages.users;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import pages.components.baseComponents.PaginationControls;
import pages.components.grid.BasicGrid;
import java.util.ArrayList;
......@@ -12,10 +13,10 @@ public class UsersGrid extends BasicGrid {
public UsersGrid(WebDriver driver, WebElement container) {
super(driver, container);
}
public List<UserRowInfo> getRows(){
public List<UserRowInfo> getRows() {
List<UserRowInfo> rowInfos = new ArrayList<>();
for (WebElement gridRow : gridRows) {
List<WebElement> cells = gridRow.findElements(By.tagName("datatable-body-cell"));
UserRowInfo rowInfo = new UserRowInfo();
......@@ -26,7 +27,76 @@ public class UsersGrid extends BasicGrid {
}
return rowInfos;
}
public boolean isUserListed(String username) {
boolean end = false;
PaginationControls pagination = new PaginationControls(driver);
pagination.skipToFirstPage();
do {
List<UserRowInfo> rows = getRows();
for (UserRowInfo row : rows) {
if (row.getUsername().equalsIgnoreCase(username)) {
return true;
}
}
try {
pagination.goToNextPage();
} catch (Exception e) {
}
} while (pagination.hasNextPage());
return false;
}
public int scrollToUser(String username) {
PaginationControls pagination = new PaginationControls(driver);
pagination.skipToFirstPage();
do {
List<UserRowInfo> rows = getRows();
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).getUsername().equalsIgnoreCase(username)) {
return i;
}
}
try {
pagination.goToNextPage();
} catch (Exception e) {
}
} while (pagination.hasNextPage());
return -1;
}
public int scrollToUserWithRole(String role) {
PaginationControls pagination = new PaginationControls(driver);
pagination.skipToFirstPage();
do {
List<UserRowInfo> rows = getRows();
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).getRole().equalsIgnoreCase(role)) {
return i;
}
}
try {
pagination.goToNextPage();
} catch (Exception e) {
}
} while (pagination.hasNextPage());
return -1;
}
}
package pages.users;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......@@ -18,7 +19,7 @@ public class UsersPage extends SMPPage {
public UsersPage(WebDriver driver) {
super(driver);
this.pageHeader.waitForTitleToBe("Users");
PageFactory.initElements( new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
}
......@@ -26,24 +27,24 @@ public class UsersPage extends SMPPage {
@FindBy(id = "searchTable")
private WebElement userTableContainer;
@FindBy(id = "cancelButton")
private WebElement cancelBtn;
@FindBy(id = "saveButton")
private WebElement saveBtn;
@FindBy(id = "newButton")
private WebElement newBtn;
@FindBy(id = "editButton")
private WebElement editBtn;
@FindBy(id = "deleteButton")
private WebElement deleteBtn;
public boolean isLoaded(){
public boolean isLoaded() {
log.info("checking Users page is loaded");
return isVisible(cancelBtn)
......@@ -53,58 +54,60 @@ public class UsersPage extends SMPPage {
&& isVisible(editBtn)
&& isVisible(deleteBtn);
}
public boolean isCancelButtonEnabled(){
public boolean isCancelButtonEnabled() {
log.info("cancel button");
return isEnabled(cancelBtn);
}
public boolean isSaveButtonEnabled(){
public boolean isSaveButtonEnabled() {
log.info("save button");
return isEnabled(saveBtn);
}
public boolean isDeleteButtonEnabled(){
public boolean isDeleteButtonEnabled() {
waitForXMillis(200);
log.info("delete button");
return isEnabled(deleteBtn);
}
public ConfirmationDialog clickCancel(){
public ConfirmationDialog clickCancel() {
log.info("click cancel button");
waitForElementToBeClickable(cancelBtn).click();
return new ConfirmationDialog(driver);
}
public ConfirmationDialog clickSave(){
public ConfirmationDialog clickSave() {
log.info("click save button");
waitForElementToBeClickable(saveBtn).click();
return new ConfirmationDialog(driver);
}
public void clickDelete(){
public void clickDelete() {
log.info("click delete button");
waitForElementToBeClickable(deleteBtn).click();
waitForRowsToLoad();
}
public UserPopup clickNew(){
public UserPopup clickNew() {
log.info("click new button");
waitForElementToBeClickable(newBtn).click();
return new UserPopup(driver);
}
public UserPopup clickEdit(){
public UserPopup clickEdit() {
log.info("click edit button");
waitForElementToBeClickable(editBtn).click();
return new UserPopup(driver);
}
public UsersGrid grid(){
public UsersGrid grid() {
return new UsersGrid(driver, userTableContainer);
}
public void createUser(){
public void createUser() {
log.info("create user");
waitForElementToBeClickable(newBtn).click();
......@@ -113,10 +116,15 @@ public class UsersPage extends SMPPage {
popup.clickOK();
}
public boolean isNewButtonEnabled() {
try {
return newBtn.isEnabled();
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
......@@ -212,7 +212,7 @@ public class DomainPgTest extends BaseTest {
soft.assertTrue(page.isLoaded(), "Check that the page is loaded");
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToDomain(rndStr);
int index = page.grid().scrollToDomain(rndStr);
page.grid().selectRow(index);
......@@ -226,14 +226,14 @@ public class DomainPgTest extends BaseTest {
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
soft.assertTrue(isDomainStillPresent(rndStr), "Row is still present");
soft.assertTrue(page.grid().isDomainStillPresent(rndStr), "Row is still present");
index = scrollToDomain(rndStr);
page.grid().selectRow(index);
page.clickDelete();
page.clickSave().confirm();
index = page.grid().scrollToDomain(rndStr);
page.grid().selectRow(index);
page.clickDelete();
page.clickSave().confirm();
soft.assertTrue(!isDomainStillPresent(rndStr), "Row is still NOT present after delete");
soft.assertTrue(!page.grid().isDomainStillPresent(rndStr), "Row is still NOT present after delete");
soft.assertAll();
......@@ -256,9 +256,9 @@ public class DomainPgTest extends BaseTest {
DomainPage page = new DomainPage(driver);
page.refreshPage();
int index = scrollToDomain(domainName);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index = page.grid().scrollToDomain(domainName);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
AlertMessage message = page.alertArea.getAlertMessage();
......@@ -271,55 +271,70 @@ public class DomainPgTest extends BaseTest {
soft.assertAll();
}
private boolean isDomainStillPresent(String domainCode){
boolean end = false;
List<DomainRow> rows = new ArrayList<>();
DomainPage page = new DomainPage(driver);
page.pagination.skipToFirstPage();
while (!end) {
page = new DomainPage(driver);
rows.addAll(page.grid().getRowsInfo());
if(page.pagination.hasNextPage()){
page.pagination.goToNextPage();
}else{end = true;}
}
boolean found = false;
for (DomainRow row : rows) {
if(row.getDomainCode().equalsIgnoreCase(domainCode)){
found = true;
}
}
return found;
}
private int scrollToDomain(String domainCode){
DomainPage page = new DomainPage(driver);
page.pagination.skipToFirstPage();
boolean end = false;
while (!end) {
page = new DomainPage(driver);
List<DomainRow> rows = page.grid().getRowsInfo();
for (int i = 0; i < rows.size(); i++) {
if(rows.get(i).getDomainCode().equalsIgnoreCase(domainCode)){
return i;
}
}
if(page.pagination.hasNextPage()){
page.pagination.goToNextPage();
}else{end = true;}
}
return -1;
}
@Test(description = "DMN-60")
public void duplicateDomainCreation() {
SoftAssert soft = new SoftAssert();
DomainPage page = new DomainPage(driver);
String errorMsg = "The Domain code already exists!";
soft.assertTrue(page.isLoaded(), "Check that the page is loaded");
String rndString = Generator.randomAlphaNumeric(10);
DomainPopup popup = page.clickNew();
soft.assertTrue(popup.isLoaded(), "Domain popup is loaded");
soft.assertTrue(popup.isDomainCodeInputEnabled(), "When defining new domain - Domain Code input is disabled");
soft.assertTrue(popup.isSMLDomainInputEnabled(), "When defining new domain -SML Domain input is disabled");
popup.fillDataForNewDomain(rndString, rndString, rndString, rndString);
popup.clickOK();
soft.assertTrue(page.isSaveButtonEnabled(), "Save button is enabled");
page.clickSave().confirm();
page.clickNew();
soft.assertTrue(popup.isLoaded(), "Domain popup is loaded");
soft.assertTrue(popup.isDomainCodeInputEnabled(), "When defining new domain - Domain Code input is disabled");
soft.assertTrue(popup.isSMLDomainInputEnabled(), "When defining new domain -SML Domain input is disabled");
popup.fillDataForNewDomain(rndString, rndString, rndString, rndString);
soft.assertEquals(popup.getDuplicateDomainErrorMsgText(), errorMsg, "The message is not matching with our expected error message");
soft.assertFalse(popup.isEnableOkButton(), "Ok button is enable");
soft.assertTrue(popup.isEnableCancelButton(), "Cancel button is disabled");
popup.clickCancel();
soft.assertAll();
}
@Test(description = "DMN-70")
public void onlyDomainCodeSavingMsgVerify() {
SoftAssert soft = new SoftAssert();
DomainPage page = new DomainPage(driver);
// String errorMsg = "The domain should have a defined signature CertAlias.";
soft.assertTrue(page.isLoaded(), "Check that the page is loaded");
int index = page.grid().scrollToSmlDomain("");
if (index >= 0) {
try {
page.grid().selectRow(index);
page.clickDelete();
page.clickSave().confirm();
} catch (Exception e) {
e.printStackTrace();
}
}
String rndString = Generator.randomAlphaNumeric(10);
DomainPopup popup = page.clickNew();
soft.assertTrue(popup.isLoaded(), "Domain popup is loaded");
soft.assertTrue(popup.isDomainCodeInputEnabled(), "When defining new domain - Domain Code input is disabled");
popup.clearAndFillDomainCodeInput(rndString);
soft.assertTrue(popup.isEnableOkButton(), "Ok button is disabled");
popup.clickOK();
soft.assertTrue(page.isSaveButtonEnabled(), "Save button is enabled");
page.clickSave().confirm();
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18),
"Success message is as expected");
index = page.grid().scrollToSmlDomain("");
if (index >= 0) {
page.grid().scrollRow(index);
}
int rowNumber = index + 1;
page.grid().mouseHoverOnDomainCode(rowNumber);
// WebElement text = driver.findElement(By.xpath("//*[text()='The domain should have a defined signature CertAlias.']"));
// soft.assertEquals(text.getText(),errorMsg, "the message 'The domain should have a defined signature CertAlias.' is not displayed");
soft.assertAll();
}
}
......@@ -8,7 +8,6 @@ import pages.components.ConfirmationDialog;
import pages.components.baseComponents.SMPPage;
import pages.components.messageArea.AlertMessage;
import pages.users.UserPopup;
import pages.users.UserRowInfo;
import pages.users.UsersPage;
import utils.Generator;
import utils.TestDataProvider;
......@@ -66,7 +65,7 @@ public class UsersPgTest extends BaseTest {
soft.assertTrue(!usersPage.alertArea.getAlertMessage().isError(), "Message listed is success");
soft.assertTrue(usersPage.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message listed is as expected");
soft.assertTrue(isUserListed(username), "User present in the page");
soft.assertTrue(usersPage.grid().isUserListed(username), "User present in the page");
soft.assertAll();
}
......@@ -174,23 +173,23 @@ public class UsersPgTest extends BaseTest {
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled after user is deleted");
soft.assertTrue(page.isSaveButtonEnabled(), "Save button is enabled after user is deleted");
soft.assertTrue(page.isCancelButtonEnabled(), "Cancel button is enabled after user is deleted");
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
soft.assertTrue(isUserListed(username), "After canceling delete user is still listed");
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
soft.assertTrue(page.grid().isUserListed(username), "After canceling delete user is still listed");
index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select(2)");
index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select(2)");
page.clickDelete();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled after user is deleted(2)");
......@@ -199,8 +198,8 @@ public class UsersPgTest extends BaseTest {
page.clickSave().confirm();
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message listed is as expected");
soft.assertTrue(!isUserListed(username), "After saving deleted user is not listed");
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message listed is as expected");
soft.assertTrue(!page.grid().isUserListed(username), "After saving deleted user is not listed");
soft.assertAll();
}
......@@ -210,8 +209,8 @@ public class UsersPgTest extends BaseTest {
SoftAssert soft = new SoftAssert();
UsersPage page = new UsersPage(driver);
int index = scrollToUserWithRole("SYSTEM_ADMIN");
UsersPage page = new UsersPage(driver);
int index = page.grid().scrollToUserWithRole("SYSTEM_ADMIN");
page.grid().selectRow(index);
UserPopup popup = page.clickEdit();
......@@ -227,8 +226,8 @@ public class UsersPgTest extends BaseTest {
SoftAssert soft = new SoftAssert();
UsersPage page = new UsersPage(driver);
int index = scrollToUserWithRole("SMP_ADMIN");
UsersPage page = new UsersPage(driver);
int index = page.grid().scrollToUserWithRole("SMP_ADMIN");
page.grid().selectRow(index);
UserPopup popup = page.clickEdit();
......@@ -251,9 +250,9 @@ public class UsersPgTest extends BaseTest {
UsersPage page = new UsersPage(driver);
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
AlertMessage message = page.alertArea.getAlertMessage();
......@@ -277,23 +276,23 @@ public class UsersPgTest extends BaseTest {
page.refreshPage();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled after user is deleted");
soft.assertTrue(page.isSaveButtonEnabled(), "Save button is enabled after user is deleted");
soft.assertTrue(page.isCancelButtonEnabled(), "Cancel button is enabled after user is deleted");
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
soft.assertTrue(isUserListed(username), "After canceling delete user is still listed");
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
soft.assertTrue(page.grid().isUserListed(username), "After canceling delete user is still listed");
index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select(2)");
index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select(2)");
page.clickDelete();
page.waitForXMillis(200);
......@@ -303,8 +302,8 @@ public class UsersPgTest extends BaseTest {
page.clickSave().confirm();
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message is as expected");
soft.assertTrue(!isUserListed(username), "After saving deleted user is not listed");
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message is as expected");
soft.assertTrue(!page.grid().isUserListed(username), "After saving deleted user is not listed");
soft.assertAll();
}
......@@ -323,9 +322,9 @@ public class UsersPgTest extends BaseTest {
soft.assertTrue(!page.isDeleteButtonEnabled(), "Delete button is not enabled");
int index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index =page.grid(). scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
page.waitForRowsToLoad();
......@@ -334,14 +333,14 @@ public class UsersPgTest extends BaseTest {
soft.assertTrue(page.isSaveButtonEnabled(), "Save button is enabled after user is deleted");
soft.assertTrue(page.isCancelButtonEnabled(), "Cancel button is enabled after user is deleted");
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
page.waitForRowsToLoad();
soft.assertTrue(isUserListed(username), "After canceling delete user is still listed");
page.clickCancel().confirm();
new ConfirmationDialog(driver).confirm();
page.waitForRowsToLoad();
soft.assertTrue(page.grid().isUserListed(username), "After canceling delete user is still listed");
index = scrollToUser(username);
page.grid().selectRow(index);
index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select(2)");
......@@ -353,8 +352,8 @@ public class UsersPgTest extends BaseTest {
page.clickSave().confirm();
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message is as expected");
soft.assertTrue(!isUserListed(username), "After saving deleted user is not listed");
soft.assertTrue(page.alertArea.getAlertMessage().getMessage().equalsIgnoreCase(SMPMessages.MSG_18), "Message is as expected");
soft.assertTrue(!page.grid().isUserListed(username), "After saving deleted user is not listed");
soft.assertAll();
}
......@@ -382,9 +381,9 @@ public class UsersPgTest extends BaseTest {
UsersPage page = new UsersPage(driver);
page.refreshPage();
int index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
AlertMessage message = page.alertArea.getAlertMessage();
......@@ -419,9 +418,9 @@ public class UsersPgTest extends BaseTest {
UsersPage page = new UsersPage(driver);
page.refreshPage();
int index = scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
int index = page.grid().scrollToUser(username);
page.grid().selectRow(index);
soft.assertTrue(page.isDeleteButtonEnabled(), "Delete button is enabled after row select");
page.clickDelete();
page.waitForXMillis(500);
......@@ -432,86 +431,59 @@ public class UsersPgTest extends BaseTest {
SMPRestClient.deleteSG(pi);
SMPRestClient.deleteUser(username);
soft.assertAll();
}
private boolean isUserListed(String username) {
boolean end = false;
UsersPage page = new UsersPage(driver);
page.pagination.skipToFirstPage();
while (!end) {
page = new UsersPage(driver);
List<UserRowInfo> rows = page.grid().getRows();
for (UserRowInfo row : rows) {
if (row.getUsername().equalsIgnoreCase(username)) {
return true;
}
}
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
} else {
end = true;
}
}
return false;
}
private int scrollToUser(String username) {
UsersPage page = new UsersPage(driver);
page.pagination.skipToFirstPage();
boolean end = false;
while (!end) {
page = new UsersPage(driver);
List<UserRowInfo> rows = page.grid().getRows();
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).getUsername().equalsIgnoreCase(username)) {
return i;
}
}
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
} else {
end = true;
}
}
return -1;
}
private int scrollToUserWithRole(String role) {
UsersPage page = new UsersPage(driver);
page.pagination.skipToFirstPage();
boolean end = false;
while (!end) {
page = new UsersPage(driver);
List<UserRowInfo> rows = page.grid().getRows();
for (int i = 0; i < rows.size(); i++) {
if (rows.get(i).getRole().equalsIgnoreCase(role)) {
return i;
}
}
if (page.pagination.hasNextPage()) {
page.pagination.goToNextPage();
} else {
end = true;
}
}
return -1;
}
soft.assertAll();
}
@Test(description = "USR-121")
public void duplicateUserCreation() {
SoftAssert soft = new SoftAssert();
String userName = Generator.randomAlphaNumeric(10);
String validPass = "QW!@qw12";
// String errorMsg = "×\n" + "The operation 'update' not completed successfully. Unexpected technical error occurred.";
UsersPage page = new UsersPage(driver);
soft.assertTrue(page.isNewButtonEnabled(), "New button should be enabled");
UserPopup popup = page.clickNew();
soft.assertTrue(!popup.isOKButtonActive(), "OK button is enable before valid data is filled in the popup");
popup.rolesSelect.selectOptionWithText("SYSTEM_ADMIN");
popup.clickUserDetailsToggle();
popup.fillDetailsForm(userName, validPass, validPass);
popup.clickOK();
soft.assertTrue(page.isSaveButtonEnabled(), "Save button is enabled");
page.clickSave().confirm();
page.clickNew();
soft.assertTrue(!popup.isOKButtonActive(), "OK button is enable before valid data is filled in the popup");
popup.rolesSelect.selectOptionWithText("SYSTEM_ADMIN");
popup.clickUserDetailsToggle();
popup.fillDetailsForm(userName, validPass, validPass);
soft.assertFalse(popup.isOKButtonActive(), "OK button is enable after duplicate user name is filled in the popup");
soft.assertTrue(popup.isDuplicateUserNameErrorMsgDisPlayed(), "The user page is not containing the expected error message");
soft.assertAll();
}
@Test(description = "USR-122")
public void verifyPasswordDoNotMatch() {
String username = Generator.randomAlphaNumeric(10);
String validPass = "QW!@qw12";
String confirmPass = "AS@!gh12";
String errorMsg = "Passwords do not match";
SoftAssert soft = new SoftAssert();
UsersPage usersPage = new UsersPage(driver);
UserPopup popup = usersPage.clickNew();
soft.assertTrue(!popup.isOKButtonActive(), "OK button is enable before valid data is filled in the popup");
popup.rolesSelect.selectOptionWithText("SMP_ADMIN");
popup.clickUserDetailsToggle();
popup.fillDetailsForm(username, validPass, confirmPass);
soft.assertTrue(!popup.isOKButtonActive(), "OK button is enabled before valid data is filled in the popup(2)");
soft.assertEquals(popup.getPassDontMatchValidationMsg(), errorMsg, "confirmation input does not contain the message 'Passwords do not match' .");
soft.assertAll();
}
}
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