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

Skip to content
Snippets Groups Projects
Commit 3271011b authored by Sonali MOHANTY's avatar Sonali MOHANTY
Browse files

Pull request #223: RestBaseIssue

Merge in EDELIVERY/smp from restBaseIssue to development

* commit 'c034e6ebbd93f0616df92f85f13f624eca50a6c1':
  minor fixes
  minor fixes and reformating
  1)some locators got changed and new locators have added.
  1)some locators got changed and new locators have added.
  1)some locators got changed and new locators have added.
  1)some locators got changed and new locators have added.
  1)some locators got changed and new locators have added.
  1)some locators got changed and new locators have added.
  1)Necessary locators are changed and some locator got added. 2)Some testcases got modified in user page since the functionliyty of user page got changed.
  1)some locators got changed and new locators have added.
  1)Necessary locators are changed and some locator got added. 2)Some new testcases added.
  1)Necessary locators are changed and some locator got added. 2)Some testcases got modified in user page since the functionliyty of user page got changed.
  1)Necessary locators are changed and some locator got added. 2)Some testcases got modified in user page since the functionliyty of user page got changed.
parents 69c053ee 4e2e72b5
No related branches found
No related tags found
No related merge requests found
Showing
with 1065 additions and 584 deletions
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<failIfNoTests>true</failIfNoTests> <failIfNoTests>true</failIfNoTests>
<systemPropertyVariables> <systemPropertyVariables>
<webdriver.chrome.driver>${chrome.driver.path}</webdriver.chrome.driver> <webdriver.chrome.driver>${chrome.driver.path}</webdriver.chrome.driver>
<webdriver.gecko.driver>geckodriver.exe</webdriver.gecko.driver> <webdriver.gecko.driver>chromedriver.exe</webdriver.gecko.driver>
<reports.folder>./target/</reports.folder> <reports.folder>./target/</reports.folder>
<data.folder>.\src\main\resources\</data.folder> <data.folder>.\src\main\resources\</data.folder>
<testdata.file>testData.json</testdata.file> <testdata.file>testData.json</testdata.file>
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
<failIfNoTests>true</failIfNoTests> <failIfNoTests>true</failIfNoTests>
<systemPropertyVariables> <systemPropertyVariables>
<webdriver.gecko.driver>${gecko.driver.path}</webdriver.gecko.driver> <webdriver.chrome.driver>${chrome.driver.path}</webdriver.chrome.driver>
<reports.folder>./target/</reports.folder> <reports.folder>./target/</reports.folder>
<data.folder>./src/main/resources/</data.folder> <data.folder>./src/main/resources/</data.folder>
<testdata.file>testData.json</testdata.file> <testdata.file>testData.json</testdata.file>
......
package pages.components; package pages.components;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
...@@ -34,6 +36,9 @@ public class ConfirmationDialog extends PageComponent { ...@@ -34,6 +36,9 @@ public class ConfirmationDialog extends PageComponent {
public void cancel(){ public void cancel(){
log.info("dialog .. cancel"); log.info("dialog .. cancel");
waitForElementToBeClickable(noBtn); waitForElementToBeClickable(noBtn);
/* Actions actions = new Actions(driver);
actions.moveToElement(noBtn).click().build().perform();*/
//((JavascriptExecutor) driver).executeScript("arguments[0].click();", noBtn);
noBtn.click(); noBtn.click();
waitForElementToBeGone(noBtn); waitForElementToBeGone(noBtn);
} }
......
...@@ -65,6 +65,7 @@ public class GenericSelect extends PageComponent { ...@@ -65,6 +65,7 @@ public class GenericSelect extends PageComponent {
if(option.getText().trim().equalsIgnoreCase(text)){ if(option.getText().trim().equalsIgnoreCase(text)){
waitForElementToBeClickable(option).click(); waitForElementToBeClickable(option).click();
waitForElementToBeGone(option); waitForElementToBeGone(option);
log.info("return type is True");
return true; return true;
} }
} }
......
...@@ -6,6 +6,7 @@ import org.openqa.selenium.support.FindBy; ...@@ -6,6 +6,7 @@ import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.components.baseComponents.PageComponent; import pages.components.baseComponents.PageComponent;
import pages.password.PasswordChangepopup;
import pages.service_groups.search.SearchPage; import pages.service_groups.search.SearchPage;
import utils.PROPERTIES; import utils.PROPERTIES;
...@@ -32,6 +33,10 @@ public class SandwichMenu extends PageComponent { ...@@ -32,6 +33,10 @@ public class SandwichMenu extends PageComponent {
@FindBy(id = "logout_id") @FindBy(id = "logout_id")
WebElement logoutLnk; WebElement logoutLnk;
@FindBy(id = "changePassword_id")
WebElement passChangeLnk;
public boolean isLoggedIn(){ public boolean isLoggedIn(){
clickVoidSpace(); clickVoidSpace();
...@@ -48,6 +53,12 @@ public class SandwichMenu extends PageComponent { ...@@ -48,6 +53,12 @@ public class SandwichMenu extends PageComponent {
clickVoidSpace(); clickVoidSpace();
return isLoggedIn; return isLoggedIn;
} }
public PasswordChangepopup clickChangePasswordOption()
{
waitForElementToBeClickable(expandoButton).click();
waitForElementToBeClickable(passChangeLnk).click();
return new PasswordChangepopup(driver);
}
public SearchPage logout(){ public SearchPage logout(){
clickVoidSpace(); clickVoidSpace();
......
...@@ -9,6 +9,7 @@ import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; ...@@ -9,6 +9,7 @@ import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.components.baseComponents.Header; import pages.components.baseComponents.Header;
import pages.components.baseComponents.SMPPage; import pages.components.baseComponents.SMPPage;
import pages.components.baseComponents.PageComponent; import pages.components.baseComponents.PageComponent;
import pages.service_groups.search.SearchPage;
import utils.PROPERTIES; import utils.PROPERTIES;
import java.security.PublicKey; import java.security.PublicKey;
...@@ -40,6 +41,9 @@ public class Sidebar extends PageComponent { ...@@ -40,6 +41,9 @@ public class Sidebar extends PageComponent {
@FindBy(id = "sidebar_user_id") @FindBy(id = "sidebar_user_id")
private WebElement userLnk; private WebElement userLnk;
@FindBy(id = "sidebar_property_id")
private WebElement propertyLnk;
@FindBy(css = "mat-icon[role=img][mattooltip=Collapse]") @FindBy(css = "mat-icon[role=img][mattooltip=Collapse]")
private WebElement collapseButton; private WebElement collapseButton;
...@@ -64,6 +68,9 @@ public class Sidebar extends PageComponent { ...@@ -64,6 +68,9 @@ public class Sidebar extends PageComponent {
case "UsersPage": case "UsersPage":
waitForElementToBeClickable(userLnk).click(); waitForElementToBeClickable(userLnk).click();
break; break;
case "PropertiesPage":
waitForElementToBeClickable(propertyLnk).click();
break;
} }
waitForXMillis(500); waitForXMillis(500);
......
...@@ -5,9 +5,9 @@ import org.openqa.selenium.WebElement; ...@@ -5,9 +5,9 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import pages.components.SandwichMenu; import pages.components.SandwichMenu;
import pages.login.LoginPage; import pages.login.LoginPage;
import pages.password.PasswordChangepopup;
import utils.PROPERTIES; import utils.PROPERTIES;
public class Header extends PageComponent{ public class Header extends PageComponent{
...@@ -29,8 +29,18 @@ public class Header extends PageComponent{ ...@@ -29,8 +29,18 @@ public class Header extends PageComponent{
@FindBy(css = "#sandwichMenu .ng-star-inserted") @FindBy(css = "#sandwichMenu .ng-star-inserted")
private WebElement role; private WebElement role;
@FindBy(css = "#changePassword_id")
private WebElement changePasswordOption;
public SandwichMenu sandwichMenu = new SandwichMenu(driver); public SandwichMenu sandwichMenu = new SandwichMenu(driver);
public PasswordChangepopup clickChangePasswordOption()
{
log.info("Clicking on changepassword option");
waitForElementToBeClickable(changePasswordOption).click();
return new PasswordChangepopup(driver);
}
public LoginPage goToLogin(){ public LoginPage goToLogin(){
log.info("Going to login page"); log.info("Going to login page");
waitForElementToBeClickable(loginLnk).click(); waitForElementToBeClickable(loginLnk).click();
......
...@@ -2,7 +2,10 @@ package pages.components.baseComponents; ...@@ -2,7 +2,10 @@ package pages.components.baseComponents;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.openqa.selenium.*; import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.support.ui.WebDriverWait;
...@@ -11,235 +14,220 @@ import utils.PROPERTIES; ...@@ -11,235 +14,220 @@ import utils.PROPERTIES;
public class PageComponent { public class PageComponent {
protected WebDriver driver; protected WebDriver driver;
protected WebDriverWait wait; protected WebDriverWait wait;
protected Logger log = Logger.getLogger(this.getClass()); protected Logger log = Logger.getLogger(this.getClass());
protected By loadingBar = By.className("mat-ripple-element");
public PageComponent(WebDriver driver) {
this.driver = driver; public PageComponent(WebDriver driver) {
this.wait = new WebDriverWait(this.driver, PROPERTIES.TIMEOUT); this.driver = driver;
} this.wait = new WebDriverWait(this.driver, PROPERTIES.TIMEOUT);
}
public WebElement waitForElementToBeClickable(WebElement element) { public WebElement waitForElementToBeClickable(WebElement element) {
return wait.until(ExpectedConditions.elementToBeClickable(element)); return wait.until(ExpectedConditions.elementToBeClickable(element));
} }
public WebElement waitForElementToBeVisible(WebElement element) { public WebElement waitForElementToBeVisible(WebElement element) {
return wait.until(ExpectedConditions.visibilityOf(element)); return wait.until(ExpectedConditions.visibilityOf(element));
} }
public WebElement waitForElementToBeVisible(By elementSelector) { public WebElement waitForElementToBeVisible(By elementSelector) {
return wait.until(ExpectedConditions.visibilityOfElementLocated(elementSelector)); return wait.until(ExpectedConditions.visibilityOfElementLocated(elementSelector));
} }
public void waitForElementToBeEnabled(WebElement element) { public void waitForElementToBeEnabled(WebElement element) {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000; int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0; int waitedSoFar = 0;
while ((null != element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) { while ((null != element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300; waitedSoFar += 300;
waitForXMillis(300); waitForXMillis(300);
} }
} }
public void waitForElementToBeDisabled(WebElement element) { public void waitForElementToBeDisabled(WebElement element) {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000; int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0; int waitedSoFar = 0;
while ((null == element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) { while ((null == element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300; waitedSoFar += 300;
waitForXMillis(300); waitForXMillis(300);
} }
} }
public void waitForElementToBeGone(WebElement element) {
public void waitForElementToBeGone(WebElement element) { WebDriverWait myWait = new WebDriverWait(driver, 1);
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
try {
try { myWait.until(ExpectedConditions.visibilityOf(element));
myWait.until(ExpectedConditions.visibilityOf(element)); myWait.until(ExpectedConditions.invisibilityOf(element));
} catch (Exception e) { } catch (Exception e) {
return; return;
} }
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000; int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) { while (waitTime > 0) {
boolean displayed = true;
try {
try { if (!element.isDisplayed()) {
displayed = element.isDisplayed(); return;
} catch (Exception e) { }
return; } catch (Exception e) {
} return;
}
if (!displayed) { waitForXMillis(500);
return; waitTime = waitTime - 500;
} }
waitForXMillis(500); }
waitTime = waitTime - 500;
} public void waitForElementToBeGone(By locator) {
} WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
public void waitForElementToBeGone(By locator) { try {
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT); myWait.until(ExpectedConditions.visibilityOfElementLocated(locator));
} catch (Exception e) {
try { return;
myWait.until(ExpectedConditions.visibilityOfElementLocated(locator)); }
} catch (Exception e) {
return; int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
} while (waitTime > 0) {
boolean displayed = true;
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) { try {
boolean displayed = true; displayed = driver.findElement(locator).isDisplayed();
} catch (Exception e) {
try { return;
displayed = driver.findElement(locator).isDisplayed(); }
} catch (Exception e) {
return; if (!displayed) {
} return;
}
if (!displayed) {
return; waitForXMillis(500);
} waitTime = waitTime - 500;
}
waitForXMillis(500); }
waitTime = waitTime - 500;
} public void waitForNumberOfWindowsToBe(int noOfWindows) {
} try {
wait.until(numberOfWindowsToBe(noOfWindows));
public void waitForNumberOfWindowsToBe(int noOfWindows) { } catch (Exception e) {
try { }
wait.until(numberOfWindowsToBe(noOfWindows)); }
} catch (Exception e) {
} public void clearAndFillInput(WebElement element, String toFill) {
}
log.info("clearing input");
public void clearAndFillInput(WebElement element, String toFill) { waitForElementToBeEnabled(element);
waitForElementToBeVisible(element).clear(); element.clear();
log.info("cleared input"); element.sendKeys(toFill);
waitForElementToBeEnabled(element); log.info("filled in text " + toFill);
element.sendKeys(toFill); }
log.info("filled in text " + toFill);
} public void clickVoidSpace() {
log.info("clicking void");
public void clickVoidSpace() { try {
log.info("clicking void"); waitForXMillis(500);
try { ((JavascriptExecutor) driver).executeScript("document.querySelector('[class*=\"overlay-backdrop\"]').click()");
waitForXMillis(500); waitForXMillis(500);
((JavascriptExecutor) driver).executeScript("document.querySelector('[class*=\"overlay-backdrop\"]').click()"); } catch (Exception e) {
waitForXMillis(500); }
} catch (Exception e) { waitForXMillis(500);
} }
waitForXMillis(500);
} private ExpectedCondition<Boolean> numberOfWindowsToBe(final int numberOfWindows) {
return new ExpectedCondition<Boolean>() {
private ExpectedCondition<Boolean> numberOfWindowsToBe(final int numberOfWindows) { @Override
return new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) {
@Override driver.getWindowHandles();
public Boolean apply(WebDriver driver) { return driver.getWindowHandles().size() == numberOfWindows;
driver.getWindowHandles(); }
return driver.getWindowHandles().size() == numberOfWindows; };
} }
};
} public void waitForXMillis(Integer millis) {
try {
public void waitForXMillis(Integer millis) { Thread.sleep(millis);
try { } catch (InterruptedException e) {
Thread.sleep(millis); log.error("EXCEPTION: ", e);
} catch (InterruptedException e) { }
log.error("EXCEPTION: ", e); }
}
} public void waitForAttributeNotEmpty(WebElement element, String attributeName) {
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, attributeName));
public void waitForAttributeNotEmpty(WebElement element, String attributeName) { }
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, attributeName));
} public void waitForElementToHaveText(WebElement element, String title) {
wait.until(ExpectedConditions.textToBePresentInElement(element, title));
public void waitForElementToHaveText(WebElement element, String title) { }
wait.until(ExpectedConditions.textToBePresentInElement(element, title));
} public void waitForElementToBe(WebElement element) {
public void waitForElementToBe(WebElement element) { wait.until(new ExpectedCondition<Boolean>() {
@Override
wait.until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) {
@Override return element.getLocation() != null;
public Boolean apply(WebDriver driver) { }
return element.getLocation() != null; });
}
}); }
} public void waitForAttributeToContain(WebElement element, String attributeName, String value) {
wait.until(ExpectedConditions.attributeContains(element, attributeName, value));
public void waitForAttributeToContain(WebElement element, String attributeName, String value) { }
wait.until(ExpectedConditions.attributeContains(element, attributeName, value));
} public void waitForElementToHaveText(WebElement element) {
wait.until(new ExpectedCondition<Boolean>() {
public void waitForElementToHaveText(WebElement element) { @Override
wait.until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) {
@Override return !element.getText().trim().isEmpty();
public Boolean apply(WebDriver driver) { }
return !element.getText().trim().isEmpty(); });
} }
});
} public void waitForElementToContainText(WebElement element, String text) {
wait.until(ExpectedConditions.textToBePresentInElement(element, text));
public void waitForElementToContainText(WebElement element, String text) { }
wait.until(ExpectedConditions.textToBePresentInElement(element, text));
} public boolean isVisible(WebElement element) {
log.info("checking if element is visible");
public boolean isVisible(WebElement element){
log.info("checking if element is visible"); try {
waitForElementToBe(element);
try { return element.isDisplayed();
waitForElementToBe(element); } catch (Exception e) {
return element.isDisplayed(); }
} catch (Exception e) { } return false;
return false; }
}
public boolean isEnabled(WebElement element) {
public boolean isEnabled(WebElement element){ log.info("checking if element is enabled");
log.info("checking if element is enabled"); try {
try { waitForElementToBeEnabled(element);
waitForElementToBeEnabled(element); } catch (Exception e) {
} catch (Exception e) { return false;
return false; }
} return element.isEnabled();
return element.isEnabled(); }
}
public boolean isDisabled(WebElement element) {
public boolean isDisabled(WebElement element){ log.info("checking if element is disabled");
log.info("checking if element is disabled"); try {
try { waitForElementToBeDisabled(element);
waitForElementToBeDisabled(element); } catch (Exception e) {
} catch (Exception e) { return false;
return false; }
} return true;
return true; }
}
public void waitForRowsToLoad() {
log.info("waiting for rows to load");
protected By loadingBar = By.className("mat-ripple-element"); try {
waitForElementToBeGone(loadingBar);
public void waitForRowsToLoad() { } catch (Exception e) {
log.info("waiting for rows to load"); }
try { waitForXMillis(500);
waitForElementToBeGone(loadingBar); }
// waitForElementToBeVisible(loadingBar);
//
// int bars = 1;
// int waits = 0;
// while (bars > 0 && waits < 30) {
// Object tmp = ((JavascriptExecutor) driver).executeScript("return document.querySelectorAll('.mat-ripple-element').length;");
// bars = Integer.valueOf(tmp.toString());
// waits++;
// waitForXMillis(500);
// }
// log.debug("waited for rows to load for ms = 500*" + waits);
} catch (Exception e) { }
waitForXMillis(500);
}
} }
......
package pages.components.grid; package pages.components.grid;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
...@@ -8,67 +7,65 @@ import org.openqa.selenium.interactions.Actions; ...@@ -8,67 +7,65 @@ import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory; import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import pages.components.baseComponents.PageComponent; import pages.components.baseComponents.PageComponent;
import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class BasicGrid extends PageComponent { public class BasicGrid extends PageComponent {
public BasicGrid(WebDriver driver, WebElement container) { @FindBy(css = "datatable-header div.datatable-row-center datatable-header-cell")
super(driver); protected List<WebElement> gridHeaders;
@FindBy(css = "datatable-body-row > div.datatable-row-center.datatable-row-group")
log.info("Loading basic grid"); protected List<WebElement> gridRows;
waitForRowsToLoad(); protected ArrayList<String> headerTxt = new ArrayList<String>();
PageFactory.initElements( new DefaultElementLocatorFactory(container) , this);
for (int i = 0; i < gridHeaders.size(); i++) {
headerTxt.add(gridHeaders.get(i).getText().trim());
}
} public BasicGrid(WebDriver driver, WebElement container) {
super(driver);
log.info("Loading basic grid");
waitForRowsToLoad();
PageFactory.initElements(new DefaultElementLocatorFactory(container), this);
for (int i = 0; i < gridHeaders.size(); i++) {
headerTxt.add(gridHeaders.get(i).getText().trim());
}
@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") public void selectRow(int rowNumber) {
protected List<WebElement> gridRows; log.info("selecting row with number ... " + rowNumber);
if (rowNumber >= gridRows.size()) {
return;
protected ArrayList<String> headerTxt = new ArrayList<String>(); }
gridRows.get(rowNumber).click();
public void selectRow(int rowNumber){ waitForXMillis(500);
log.info("selecting row with number ... " + rowNumber); }
if(rowNumber>=gridRows.size()){return;}
gridRows.get(rowNumber).click();
waitForXMillis(500);
}
public void doubleClickRow(int rowNumber){
log.info("double clicking row ... " + rowNumber);
waitForXMillis(500);
if(rowNumber>=gridRows.size()){return ;}
Actions action = new Actions(driver);
action.doubleClick(gridRows.get(rowNumber)).perform();
}
public int getColumnsNo(){ public void doubleClickRow(int rowNumber) {
log.info("getting number of columns");
return gridHeaders.size();
}
public int getRowsNo(){ log.info("double clicking row ... " + rowNumber);
return gridRows.size(); waitForXMillis(500);
} if (rowNumber >= gridRows.size()) {
return;
}
Actions action = new Actions(driver);
action.doubleClick(gridRows.get(rowNumber)).perform();
}
public void scrollRow(int index) { public int getColumnsNo() {
JavascriptExecutor js = (JavascriptExecutor) driver; log.info("getting number of columns");
js.executeScript("arguments[0].scrollIntoView();",gridRows.get(index)); return gridHeaders.size();
waitForXMillis(500); }
}
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);
}
} }
...@@ -11,7 +11,8 @@ public class AlertMessage { ...@@ -11,7 +11,8 @@ public class AlertMessage {
} }
public String getMessage() { public String getMessage() {
return message.replaceAll("×", "").trim(); System.out.println("message = " + message);
return message.replaceAll("×", "").trim();
} }
public void setMessage(String message) { public void setMessage(String message) {
......
package pages.password;
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 pages.components.ConfirmationDialog;
import pages.components.baseComponents.PageComponent;
import pages.service_groups.search.SearchPage;
import utils.PROPERTIES;
public class PasswordChangepopup extends PageComponent {
@FindBy(id = "username_id")
WebElement userNameInput;
@FindBy(id = "emailAddress_id")
WebElement emailInput;
@FindBy(id = "np_id")
WebElement newPasswordInput;
@FindBy(id = "cnp_id")
WebElement confirmationInput;
/* @FindBy(css = "input#cp_id")
WebElement adminPassInput;
*/
@FindBy(xpath = "//input[@data-placeholder='Admin password for user [system]']")
WebElement adminPassInput;
@FindBy(xpath = "//input[@data-placeholder='Current password']")
WebElement currentPassInput;
@FindBy(css = "mat-form-field.username> div > div.mat-form-field-flex > div > div")
WebElement usernameValidationError;
@FindBy(css = "mat-form-field.password > div > div.mat-form-field-flex > div > div")
WebElement passValidationError;
@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-actions button:nth-child(1)")
WebElement okBtn;
@FindBy(css = "mat-dialog-actions button:nth-child(2)")
WebElement cancelBtn;
@FindBy(css = "#changePassword_id")
WebElement changePassword;
@FindBy(css = "smp-password-change-dialog mat-dialog-actions button:nth-child(1)")
WebElement changedPassword;
@FindBy(css = "#closebuttondialog_id")
WebElement passChangedClose;
@FindBy(css = "smp-password-change-dialog mat-dialog-actions button:nth-child(2)")
WebElement passwordDialogClose;
public PasswordChangepopup(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
}
public void clickOK() {
log.info("click OK");
waitForElementToBeClickable(okBtn);
okBtn.click();
waitForElementToBeGone(okBtn);
}
public void clickCancel() {
log.info("click cancel");
waitForElementToBeClickable(cancelBtn);
cancelBtn.click();
waitForElementToBeGone(cancelBtn);
}
public void clickChangePassword() {
log.info("click change password");
waitForElementToBeClickable(changePassword);
changePassword.click();
//waitForElementToBeGone(changePassword);
}
public SearchPage clickCloseAfterChangedPassForLoggedUser() {
log.info("click close after change password");
waitForElementToBeClickable(passChangedClose);
passChangedClose.click();
waitForElementToBeGone(passChangedClose);
return new SearchPage(driver);
}
public void clickCloseAfterChangedPass() {
log.info("click close after change password");
waitForElementToBeClickable(passChangedClose);
passChangedClose.click();
waitForElementToBeGone(passChangedClose);
}
public void setOrChangePassword(String adminPass, String newPass, String confirmPass) {
clearAndFillInput(adminPassInput, adminPass);
clearAndFillInput(newPasswordInput, newPass);
clearAndFillInput(confirmationInput, confirmPass);
}
public void fillDataForLoggedUser(String currentPass, String newPass, String confirmPass) {
clearAndFillInput(currentPassInput, currentPass);
clearAndFillInput(newPasswordInput, newPass);
clearAndFillInput(confirmationInput, confirmPass);
}
public ConfirmationDialog clickChangedPassword() {
log.info("click changed password");
waitForElementToBeClickable(changedPassword);
changedPassword.click();
waitForElementToBeGone(changedPassword);
return new ConfirmationDialog(driver);
}
public SearchPage clickClosePasswordDialog() {
passwordDialogClose.click();
waitForElementToBeGone(passwordDialogClose);
return new SearchPage(driver);
}
public boolean isCurrentPasswordInputEnable() {
boolean bool = currentPassInput.isEnabled();
return bool;
}
public boolean isNewPasswordInputEnable() {
boolean bool = newPasswordInput.isEnabled();
return bool;
}
public boolean isConfirmPasswordInputEnable() {
boolean bool = confirmationInput.isEnabled();
return bool;
}
}
package pages.properties;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import pages.components.grid.BasicGrid;
import pages.properties.PropertyRowInfo;
import pages.users.UserRowInfo;
import java.util.ArrayList;
import java.util.List;
public class PropertiesGrid extends BasicGrid {
public PropertiesGrid(WebDriver driver, WebElement container) {
super(driver, container);
}
public List<PropertyRowInfo> getRows() {
List<PropertyRowInfo> rowInfos = new ArrayList<>();
for (WebElement gridRow : gridRows) {
List<WebElement> cells = gridRow.findElements(By.tagName("datatable-body-cell"));
PropertyRowInfo rowInfo = new PropertyRowInfo();
rowInfo.setPropertyname(cells.get(0).getText().trim());
rowInfo.setPropertyvalue(cells.get(1).getText().trim());
rowInfos.add(rowInfo);
}
return rowInfos;
}
public Boolean rowContainPropertyName(String property){
List<PropertyRowInfo> rows = getRows();
int i = rows.size();
Boolean bool=rows.size() == 1 && rows.get(i-1).getPropertyname().equalsIgnoreCase(property);
return bool;
}
}
package pages.properties;
import org.openqa.selenium.By;
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 pages.components.ConfirmationDialog;
import pages.components.baseComponents.PaginationControls;
import pages.components.baseComponents.SMPPage;
import pages.users.UserPopup;
import pages.users.UsersGrid;
import utils.PROPERTIES;
public class PropertiesPage extends SMPPage {
public PropertiesPage(WebDriver driver) {
super(driver);
this.pageHeader.waitForTitleToBe("Properties");
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
}
public PaginationControls pagination = new PaginationControls(driver);
@FindBy(id = "searchTable")
private WebElement propertyTableContainer;
@FindBy(id = "cancelButton")
private WebElement cancelBtn;
@FindBy(id = "saveButton")
private WebElement saveBtn;
@FindBy(id = "editButton")
private WebElement editBtn;
@FindBy(id = "searchProperty")
private WebElement searchPropertyField;
@FindBy(id = "searchbutton_id")
private WebElement searchBtn;
public String getErrorMessage()
{
return driver.findElement(By.cssSelector(".alert-message-error")).getText();
}
public boolean isLoaded(){
log.info("checking if Property page is loaded");
return isVisible(cancelBtn)
&& isVisible(saveBtn)
&& isVisible(editBtn);
}
public boolean isCancelButtonEnabled() {
log.info("checking cancel button is enabled");
return isEnabled(cancelBtn);
}
public boolean isSaveButtonEnabled() {
log.info("checking save button is enabled");
return isEnabled(saveBtn);
}
public ConfirmationDialog clickCancel() {
log.info("click cancel button");
waitForElementToBeClickable(cancelBtn).click();
return new ConfirmationDialog(driver);
}
public boolean isEditButtonEnabled() {
log.info("checking edit button is enabled");
return isEnabled(editBtn);
}
public ConfirmationDialog clickSave() {
log.info("click save button");
waitForElementToBeClickable(saveBtn).click();
return new ConfirmationDialog(driver);
}
public PropertyPopup clickEdit() {
log.info("click edit button");
waitForElementToBeClickable(editBtn).click();
return new PropertyPopup(driver);
}
public void propertySearch(String propertyname)
{
log.info("Search for property");
waitForElementToBeVisible(searchPropertyField).sendKeys(propertyname);
waitForElementToBeClickable(searchBtn).click();
}
public PropertiesGrid grid() {
return new PropertiesGrid(driver, propertyTableContainer);
}
}
package pages.properties;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import pages.components.GenericSelect;
import pages.components.baseComponents.PageComponent;
public class PropertyPopup extends PageComponent {
public PropertyPopup(WebDriver driver) {
super(driver);
PageFactory.initElements(driver, this);
}
@FindBy(css = "mat-dialog-actions button:nth-child(1)")
WebElement popupOkBtn;
@FindBy(css = "mat-dialog-actions button:nth-child(2)")
WebElement popupCancelBtn;
@FindBy(css = "span.mat-checkbox-inner-container input")
WebElement propertyCheckbox;
@FindBy(css = ".mat-input-element.mat-form-field-autofill-control[type='text']")
WebElement propertryEditInput;
public boolean isOKButtonActive() {
return isEnabled(popupOkBtn);
}
public boolean isCancelButtonActive() {
return isEnabled(popupCancelBtn);
}
public PropertiesPage clickOK() {
log.info("click OK");
waitForElementToBeClickable(popupOkBtn);
popupOkBtn.click();
waitForElementToBeGone(popupOkBtn);
return new PropertiesPage(driver);
}
public PropertiesPage clickCancel() {
log.info("click cancel");
waitForElementToBeClickable(popupCancelBtn);
popupCancelBtn.click();
waitForElementToBeGone(popupCancelBtn);
return new PropertiesPage(driver);
}
public PropertiesPage enableCheckboxOfProperty() {
Boolean bool = propertyCheckbox.isSelected();
if (bool == false) {
propertyCheckbox.click();
popupOkBtn.click();
}
else
{
popupCancelBtn.click();
}
return new PropertiesPage(driver);
}
public PropertiesPage disableCheckboxOfProperty(){
Boolean bool = propertyCheckbox.isSelected();
if(bool == true){
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", propertyCheckbox);
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
popupOkBtn.click();
}
else
{
popupCancelBtn.click();
}
return new PropertiesPage(driver);
}
public void editInputField(String string)
{
propertryEditInput.sendKeys(string);
}
}
package pages.properties;
public class PropertyRowInfo {
private String propertyname;
private String propertyvalue;
public String getPropertyname() {
return propertyname;
}
public void setPropertyname(String propertyname) {
this.propertyname = propertyname;
}
public String getPropertyvalue() {
return propertyvalue;
}
public void setPropertyvalue(String propertyvalue) {
this.propertyvalue = propertyvalue;
}
}
...@@ -29,6 +29,9 @@ public class EditPage extends SMPPage { ...@@ -29,6 +29,9 @@ public class EditPage extends SMPPage {
@FindBy(id = "searchTable") @FindBy(id = "searchTable")
private WebElement searchTable; private WebElement searchTable;
@FindBy(id = "okButton")
private WebElement okButton;
@FindBy(id = "cancelButton") @FindBy(id = "cancelButton")
private WebElement cancelButton; private WebElement cancelButton;
...@@ -101,6 +104,11 @@ public class EditPage extends SMPPage { ...@@ -101,6 +104,11 @@ public class EditPage extends SMPPage {
waitForElementToBeClickable(cancelButton).click(); waitForElementToBeClickable(cancelButton).click();
return new ConfirmationDialog(driver); return new ConfirmationDialog(driver);
} }
public ConfirmationDialog clickOk() {
log.info("canceling ...");
waitForElementToBeClickable(okButton).click();
return new ConfirmationDialog(driver);
}
public void clickDelete() { public void clickDelete() {
log.info("deleting ..."); log.info("deleting ...");
......
...@@ -33,10 +33,10 @@ public class ServiceGroupPopup extends PageComponent { ...@@ -33,10 +33,10 @@ public class ServiceGroupPopup extends PageComponent {
private WebElement domainsPanelContainer; private WebElement domainsPanelContainer;
public AccordionSection domainsPanel; public AccordionSection domainsPanel;
@FindBy(css = "mat-dialog-actions > div > button:nth-child(1)") @FindBy(css = "mat-dialog-actions button:nth-child(1)")
private WebElement okButton; private WebElement okButton;
@FindBy(css = "mat-dialog-actions > div > button:nth-child(2)") @FindBy(css = "mat-dialog-actions button:nth-child(2)")
private WebElement cancelButton; private WebElement cancelButton;
@FindBy(css = "#participantIdentifier_id") @FindBy(css = "#participantIdentifier_id")
...@@ -57,7 +57,7 @@ public class ServiceGroupPopup extends PageComponent { ...@@ -57,7 +57,7 @@ public class ServiceGroupPopup extends PageComponent {
@FindBy(css = "mat-card-content > mat-toolbar > mat-toolbar-row > button:nth-child(3)") @FindBy(css = "mat-card-content > mat-toolbar > mat-toolbar-row > button:nth-child(3)")
private WebElement validateExtensionButton; private WebElement validateExtensionButton;
@FindBy(css = "mat-card-content > div > div.ng-star-inserted") @FindBy(css = "mat-card-content > div.ng-star-inserted")
private WebElement errorContainer; private WebElement errorContainer;
...@@ -69,6 +69,14 @@ public class ServiceGroupPopup extends PageComponent { ...@@ -69,6 +69,14 @@ public class ServiceGroupPopup extends PageComponent {
log.info("is cancel button visible"); log.info("is cancel button visible");
return isVisible(cancelButton); return isVisible(cancelButton);
} }
public boolean isOKButtonEnable(){
log.info("is ok button visible");
return isEnabled(okButton);
}
public boolean isCancelButtonEnable(){
log.info("is cancel button visible");
return isEnabled(cancelButton);
}
public boolean isExtensionAreaEditable(){ public boolean isExtensionAreaEditable(){
log.info("is Extension Area Editable"); log.info("is Extension Area Editable");
...@@ -114,7 +122,7 @@ public class ServiceGroupPopup extends PageComponent { ...@@ -114,7 +122,7 @@ public class ServiceGroupPopup extends PageComponent {
public void clickCancel(){ public void clickCancel(){
log.info("click cancel.."); log.info("click cancel..");
waitForElementToBeClickable(cancelButton).click(); waitForElementToBeClickable(cancelButton).click();
waitForElementToBeGone(okButton); waitForElementToBeGone(cancelButton);
} }
public void fillForm(String identifier, String scheme, List<String> owners, List<String> domains, String extension){ public void fillForm(String identifier, String scheme, List<String> owners, List<String> domains, String extension){
......
...@@ -5,146 +5,233 @@ import org.openqa.selenium.WebDriver; ...@@ -5,146 +5,233 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import pages.components.ConfirmationDialog;
import pages.components.GenericSelect; import pages.components.GenericSelect;
import pages.components.baseComponents.PageComponent; import pages.components.baseComponents.PageComponent;
public class UserPopup extends PageComponent { public class UserPopup extends PageComponent {
public UserPopup(WebDriver driver) { public GenericSelect rolesSelect;
super(driver); @FindBy(id = "userDetailsToggle_id")
PageFactory.initElements(driver, this); WebElement userDetailsToggle;
rolesSelect = new GenericSelect(driver, rolesSelectContainer);
}
@FindBy(css = "#active_id > label > div > div")
WebElement activeToggle;
@FindBy(id = "userDetailsToggle_id") @FindBy(id = "username_id")
WebElement userDetailsToggle; WebElement userNameInput;
@FindBy(css = "#active_id > label > div > div") @FindBy(id = "emailAddress_id")
WebElement activeToggle; WebElement emailInput;
@FindBy(id = "username_id") @FindBy(id = "np_id")
WebElement userNameInput; WebElement newPasswordInput;
@FindBy(id = "emailAddress_id") @SuppressWarnings("SpellCheckingInspection")
WebElement emailInput; @FindBy(id = "cnp_id")
WebElement confirmationInput;
@FindBy(id = "password_id") @FindBy(css = "input#cp_id")
WebElement passwordInput; WebElement adminPassInput;
@SuppressWarnings("SpellCheckingInspection") @FindBy(css = "mat-form-field.username> div > div.mat-form-field-flex > div > div")
@FindBy(id = "usernameconfirmation_id") WebElement usernameValidationError;
WebElement confirmationInput;
@FindBy(css = "mat-form-field.username> div > div.mat-form-field-flex > div > div") @FindBy(css = "smp-password-change-dialog .password-panel mat-form-field:nth-child(2) .mat-form-field-subscript-wrapper mat-error")
WebElement usernameValidationError; WebElement passValidationError;
@FindBy(css = "mat-form-field.password > div > div.mat-form-field-flex > div > div") @FindBy(css = "mat-form-field.password-confirmation > div > div.mat-form-field-flex > div > div")
WebElement passValidationError; WebElement passConfirmationValidationError;
@FindBy(css = "mat-form-field.password-confirmation > div > div.mat-form-field-flex > div > div") @FindBy(css = ".ng-trigger.ng-trigger-transitionMessages.ng-star-inserted > mat-error")
WebElement passConfirmationValidationError; WebElement passMatchValidationError;
@FindBy(css = ".mat-form-field-infix > div.has-error") @FindBy(css = "mat-dialog-actions button:nth-child(1)")
WebElement passMatchValidationError; WebElement okBtn;
@FindBy(css = "mat-dialog-content > table > tr > td > button:nth-child(1)") @FindBy(css = "mat-dialog-actions button:nth-child(2)")
WebElement okBtn; WebElement cancelBtn;
@FindBy(css = "mat-dialog-content > table > tr > td > button:nth-child(2)") @FindBy(css = "#changePassword_id")
WebElement cancelBtn; WebElement changePassword;
@FindBy(css = "#role_id") @FindBy(css = "smp-password-change-dialog mat-dialog-actions button:nth-child(1)")
WebElement rolesSelectContainer; WebElement changedPassword;
public GenericSelect rolesSelect;
@FindBy(css = "#closebuttondialog_id")
WebElement passChangedClose;
public boolean isOKButtonActive() {
return isEnabled(okBtn); @FindBy(css = "smp-password-change-dialog mat-dialog-actions button:nth-child(2)")
} WebElement passwordDialogClose;
public boolean isCancelButtonActive() { @FindBy(css = "#role_id")
return isEnabled(cancelBtn); WebElement rolesSelectContainer;
} public UserPopup(WebDriver driver) {
super(driver);
public void fillData(String user, String email, String role, String password, String confirmation) { PageFactory.initElements(driver, this);
clearAndFillInput(userNameInput, user); rolesSelect = new GenericSelect(driver, rolesSelectContainer);
clearAndFillInput(emailInput, email); }
clearAndFillInput(passwordInput, password);
clearAndFillInput(confirmationInput, confirmation); public boolean isAdminPasswordInputEnable() {
boolean bool = adminPassInput.isEnabled();
GenericSelect rolesSelect = new GenericSelect(driver, rolesSelectContainer); return bool;
rolesSelect.selectOptionByText(role); }
} public boolean isNewPasswordInputEnable() {
boolean bool = newPasswordInput.isEnabled();
public void clickOK() { return bool;
log.info("click OK"); }
waitForElementToBeClickable(okBtn);
okBtn.click(); public boolean isConfirmPasswordInputEnable() {
waitForElementToBeGone(okBtn); boolean bool = confirmationInput.isEnabled();
} return bool;
}
public void clickCancel() {
log.info("click cancel");
waitForElementToBeClickable(cancelBtn); public boolean isOKButtonActive() {
cancelBtn.click(); return isEnabled(okBtn);
waitForElementToBeGone(cancelBtn); }
}
public boolean isChangePasswordActive() {
return isEnabled(passChangedClose);
public void clickUserDetailsToggle() { }
log.info("details toggle");
waitForElementToBeClickable(userDetailsToggle).click(); public boolean isChangePasswordButtonActive() {
waitForElementToBeEnabled(userNameInput); return isEnabled(changedPassword);
} }
public void fillDetailsForm(String username, String pass, String confirmation) { public boolean isCancelButtonActive() {
clearAndFillInput(userNameInput, username); return isEnabled(cancelBtn);
clearAndFillInput(passwordInput, pass); }
clearAndFillInput(confirmationInput, confirmation);
emailInput.click(); public void fillData(String user, String email, String role, String password, String confirmation) {
} clearAndFillInput(userNameInput, user);
clearAndFillInput(emailInput, email);
clearAndFillInput(newPasswordInput, password);
public String getUsernameValidationError() { clearAndFillInput(confirmationInput, confirmation);
try {
waitForElementToBeVisible(usernameValidationError); GenericSelect rolesSelect = new GenericSelect(driver, rolesSelectContainer);
return usernameValidationError.getText(); rolesSelect.selectOptionByText(role);
} catch (Exception e) {
} }
return null;
} public void clickOK() {
log.info("click OK");
public String getPassValidationError() { waitForElementToBeClickable(okBtn);
try { okBtn.click();
waitForElementToBeVisible(passValidationError); waitForElementToBeGone(okBtn);
return passValidationError.getText(); }
} catch (Exception e) {
} public void clickCancel() {
return null; log.info("click cancel");
} waitForElementToBeClickable(cancelBtn);
cancelBtn.click();
public String getConfirmationPassValidationError() { waitForElementToBeGone(cancelBtn);
}
try {
waitForElementToBeVisible(passConfirmationValidationError);
return passConfirmationValidationError.getText(); public void clickUserDetailsToggle() {
} catch (Exception e) { log.info("details toggle");
} waitForElementToBeClickable(userDetailsToggle).click();
return null; waitForElementToBeEnabled(userNameInput);
} }
public boolean isDuplicateUserNameErrorMsgDisPlayed() { //public void fillDetailsForm(String username, String pass, String confirmation)
try { public void fillDetailsForm(String username) {
return driver.findElement(By.cssSelector("mat-form-field.username > div .has-error")).isDisplayed(); clearAndFillInput(userNameInput, username);
} catch (Exception e) { //clearAndFillInput(passwordInput, pass);
e.printStackTrace(); //clearAndFillInput(confirmationInput, confirmation);
return false; emailInput.click();
} }
}
public void clickSetOrChangePassword() {
public String getPassDontMatchValidationMsg() { log.info("click change password");
// WebElement passwordUnmatchingMsg = driver.findElement(By.cssSelector(".mat-form-field-infix > div.has-error")); waitForElementToBeClickable(changePassword);
return passMatchValidationError.getText(); waitForXMillis(500);
} changePassword.click();
waitForXMillis(500);
}
public void clickCloseAfterChangedPass() {
log.info("click close after change password");
try {
Thread.sleep(10000);
} catch (Exception e) {
e.printStackTrace();
}
waitForElementToBeClickable(passChangedClose);
log.info("ab");
passChangedClose.click();
log.info("bd");
waitForElementToBeGone(passChangedClose);
log.info("cd");
}
public ConfirmationDialog clickChangedPassword() {
log.info("click changed password");
waitForElementToBeClickable(changedPassword);
waitForXMillis(500);
changedPassword.click();
waitForElementToBeGone(changedPassword);
return new ConfirmationDialog(driver);
}
public boolean isPopupChangedPasswordEnabled() {
return changedPassword.isEnabled();
}
public void setOrChangePassword(String adminPass, String newPass, String confirmPass) {
clearAndFillInput(adminPassInput, adminPass);
clearAndFillInput(newPasswordInput, newPass);
clearAndFillInput(confirmationInput, confirmPass);
}
public void clickClosePasswordDialog() {
passwordDialogClose.click();
waitForElementToBeGone(passwordDialogClose);
}
public String getUsernameValidationError() {
try {
waitForElementToBeVisible(usernameValidationError);
return usernameValidationError.getText();
} catch (Exception e) {
}
return null;
}
public String getPassValidationError() {
try {
waitForElementToBeVisible(passValidationError);
return passValidationError.getText();
} catch (Exception e) {
}
return null;
}
public String getConfirmationPassValidationError() {
try {
waitForElementToBeVisible(passConfirmationValidationError);
return passConfirmationValidationError.getText();
} catch (Exception e) {
}
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(".ng-trigger.ng-trigger-transitionMessages.ng-star-inserted > mat-error"));
return passMatchValidationError.getText();
//".mat-form-field-infix > div.has-error"
}
} }
package pages.users; package pages.users;
import org.openqa.selenium.WebDriver; public class UserRowInfo {
import org.openqa.selenium.WebElement;
private String username;
import java.util.ArrayList; private String role;
private String certificate;
public class UserRowInfo{
private String username; public String getUsername() {
private String role; return username;
private String certificate; }
public void setUsername(String username) {
public String getUsername() { this.username = username;
return username; }
}
public String getRole() {
public void setUsername(String username) { return role;
this.username = username; }
}
public void setRole(String role) {
public String getRole() { this.role = role;
return role; }
}
public String getCertificate() {
public void setRole(String role) { return certificate;
this.role = role; }
}
public void setCertificate(String certificate) {
public String getCertificate() { this.certificate = certificate;
return certificate; }
}
public void setCertificate(String certificate) {
this.certificate = certificate;
}
} }
package pages.users; package pages.users;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory; import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import pages.components.ConfirmationDialog; import pages.components.ConfirmationDialog;
import pages.components.baseComponents.PaginationControls; import pages.components.baseComponents.PaginationControls;
import pages.components.baseComponents.SMPPage; import pages.components.baseComponents.SMPPage;
import pages.components.grid.BasicGrid;
import utils.PROPERTIES; import utils.PROPERTIES;
import java.util.List;
public class UsersPage extends SMPPage { public class UsersPage extends SMPPage {
public UsersPage(WebDriver driver) { public PaginationControls pagination = new PaginationControls(driver);
super(driver); @FindBy(id = "searchTable")
this.pageHeader.waitForTitleToBe("Users"); private WebElement userTableContainer;
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this); @FindBy(id = "cancelButton")
} private WebElement cancelBtn;
@FindBy(id = "saveButton")
private WebElement saveBtn;
public PaginationControls pagination = new PaginationControls(driver); @FindBy(id = "newButton")
private WebElement newBtn;
@FindBy(id = "searchTable") @FindBy(id = "editButton")
private WebElement userTableContainer; private WebElement editBtn;
@FindBy(id = "deleteButton")
@FindBy(id = "cancelButton") private WebElement deleteBtn;
private WebElement cancelBtn;
public UsersPage(WebDriver driver) {
@FindBy(id = "saveButton") super(driver);
private WebElement saveBtn; this.pageHeader.waitForTitleToBe("Users");
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
@FindBy(id = "newButton") }
private WebElement newBtn;
public boolean isLoaded() {
@FindBy(id = "editButton") log.info("checking Users page is loaded");
private WebElement editBtn;
return isVisible(cancelBtn)
@FindBy(id = "deleteButton") && isVisible(saveBtn)
private WebElement deleteBtn; && isVisible(newBtn)
&& isEnabled(newBtn)
&& isVisible(editBtn)
public boolean isLoaded() { && isVisible(deleteBtn);
log.info("checking Users page is loaded"); }
return isVisible(cancelBtn) public boolean isCancelButtonEnabled() {
&& isVisible(saveBtn) log.info("cancel button");
&& isVisible(newBtn) return isEnabled(cancelBtn);
&& isEnabled(newBtn) }
&& isVisible(editBtn)
&& isVisible(deleteBtn); public boolean isSaveButtonEnabled() {
} log.info("save button");
return isEnabled(saveBtn);
public boolean isCancelButtonEnabled() { }
log.info("cancel button");
return isEnabled(cancelBtn); public boolean isDeleteButtonEnabled() {
} waitForXMillis(200);
log.info("delete button");
public boolean isSaveButtonEnabled() { return isEnabled(deleteBtn);
log.info("save button"); }
return isEnabled(saveBtn);
} public ConfirmationDialog clickCancel() {
log.info("click cancel button");
public boolean isDeleteButtonEnabled() { waitForElementToBeClickable(cancelBtn).click();
waitForXMillis(200); return new ConfirmationDialog(driver);
log.info("delete button"); }
return isEnabled(deleteBtn);
} public ConfirmationDialog clickSave() {
log.info("click save button");
public ConfirmationDialog clickCancel() { waitForElementToBeClickable(saveBtn).click();
log.info("click cancel button"); return new ConfirmationDialog(driver);
waitForElementToBeClickable(cancelBtn).click(); }
return new ConfirmationDialog(driver);
} public void clickDelete() {
log.info("click delete button");
public ConfirmationDialog clickSave() { waitForElementToBeClickable(deleteBtn).click();
log.info("click save button"); waitForRowsToLoad();
waitForElementToBeClickable(saveBtn).click(); }
return new ConfirmationDialog(driver);
} public UserPopup clickNew() {
log.info("click new button");
public void clickDelete() { waitForElementToBeClickable(newBtn).click();
log.info("click delete button"); return new UserPopup(driver);
waitForElementToBeClickable(deleteBtn).click(); }
waitForRowsToLoad();
} public UserPopup clickEdit() {
log.info("click edit button");
public UserPopup clickNew() { waitForElementToBeClickable(editBtn).click();
log.info("click new button"); return new UserPopup(driver);
waitForElementToBeClickable(newBtn).click(); }
return new UserPopup(driver);
}
public UsersGrid grid() {
public UserPopup clickEdit() { return new UsersGrid(driver, userTableContainer);
log.info("click edit button"); }
waitForElementToBeClickable(editBtn).click();
return new UserPopup(driver);
} public void createUser() {
log.info("create user");
public UsersGrid grid() { waitForElementToBeClickable(newBtn).click();
return new UsersGrid(driver, userTableContainer);
} UserPopup popup = new UserPopup(driver);
popup.clickOK();
public void createUser() { }
log.info("create user");
public boolean isNewButtonEnabled() {
waitForElementToBeClickable(newBtn).click(); try {
return newBtn.isEnabled();
UserPopup popup = new UserPopup(driver); } catch (Exception e) {
popup.clickOK(); e.printStackTrace();
}
} return false;
}
public boolean isNewButtonEnabled() {
try {
return newBtn.isEnabled();
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
} }
package utils; package utils;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class DriverManager { public class DriverManager {
...@@ -24,24 +20,16 @@ public class DriverManager { ...@@ -24,24 +20,16 @@ public class DriverManager {
// return driver; // return driver;
// } // }
public static WebDriver getDriver(){ public static WebDriver getDriver() {
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"true"); WebDriver driver = new ChromeDriver();
// System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"C:\\temp\\logs.txt"); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
FirefoxOptions options = new FirefoxOptions(); driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
FirefoxProfile profile= new FirefoxProfile(); driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
profile.setPreference( "layout.css.devPixelsPerPx", "0.8" );
options.setProfile(profile);
WebDriver driver = new FirefoxDriver(options);
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(2, TimeUnit.SECONDS);
driver.manage().window().maximize(); driver.manage().window().maximize();
return driver; return driver;
} }
} }
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