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 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 @@
<failIfNoTests>true</failIfNoTests>
<systemPropertyVariables>
<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>
<data.folder>.\src\main\resources\</data.folder>
<testdata.file>testData.json</testdata.file>
......@@ -110,7 +110,7 @@
<failIfNoTests>true</failIfNoTests>
<systemPropertyVariables>
<webdriver.gecko.driver>${gecko.driver.path}</webdriver.gecko.driver>
<webdriver.chrome.driver>${chrome.driver.path}</webdriver.chrome.driver>
<reports.folder>./target/</reports.folder>
<data.folder>./src/main/resources/</data.folder>
<testdata.file>testData.json</testdata.file>
......
package pages.components;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
......@@ -34,6 +36,9 @@ public class ConfirmationDialog extends PageComponent {
public void cancel(){
log.info("dialog .. cancel");
waitForElementToBeClickable(noBtn);
/* Actions actions = new Actions(driver);
actions.moveToElement(noBtn).click().build().perform();*/
//((JavascriptExecutor) driver).executeScript("arguments[0].click();", noBtn);
noBtn.click();
waitForElementToBeGone(noBtn);
}
......
......@@ -65,6 +65,7 @@ public class GenericSelect extends PageComponent {
if(option.getText().trim().equalsIgnoreCase(text)){
waitForElementToBeClickable(option).click();
waitForElementToBeGone(option);
log.info("return type is True");
return true;
}
}
......
......@@ -6,6 +6,7 @@ import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.components.baseComponents.PageComponent;
import pages.password.PasswordChangepopup;
import pages.service_groups.search.SearchPage;
import utils.PROPERTIES;
......@@ -32,6 +33,10 @@ public class SandwichMenu extends PageComponent {
@FindBy(id = "logout_id")
WebElement logoutLnk;
@FindBy(id = "changePassword_id")
WebElement passChangeLnk;
public boolean isLoggedIn(){
clickVoidSpace();
......@@ -48,6 +53,12 @@ public class SandwichMenu extends PageComponent {
clickVoidSpace();
return isLoggedIn;
}
public PasswordChangepopup clickChangePasswordOption()
{
waitForElementToBeClickable(expandoButton).click();
waitForElementToBeClickable(passChangeLnk).click();
return new PasswordChangepopup(driver);
}
public SearchPage logout(){
clickVoidSpace();
......
......@@ -9,6 +9,7 @@ import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import pages.components.baseComponents.Header;
import pages.components.baseComponents.SMPPage;
import pages.components.baseComponents.PageComponent;
import pages.service_groups.search.SearchPage;
import utils.PROPERTIES;
import java.security.PublicKey;
......@@ -40,6 +41,9 @@ public class Sidebar extends PageComponent {
@FindBy(id = "sidebar_user_id")
private WebElement userLnk;
@FindBy(id = "sidebar_property_id")
private WebElement propertyLnk;
@FindBy(css = "mat-icon[role=img][mattooltip=Collapse]")
private WebElement collapseButton;
......@@ -64,6 +68,9 @@ public class Sidebar extends PageComponent {
case "UsersPage":
waitForElementToBeClickable(userLnk).click();
break;
case "PropertiesPage":
waitForElementToBeClickable(propertyLnk).click();
break;
}
waitForXMillis(500);
......
......@@ -5,9 +5,9 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import pages.components.SandwichMenu;
import pages.login.LoginPage;
import pages.password.PasswordChangepopup;
import utils.PROPERTIES;
public class Header extends PageComponent{
......@@ -29,8 +29,18 @@ public class Header extends PageComponent{
@FindBy(css = "#sandwichMenu .ng-star-inserted")
private WebElement role;
@FindBy(css = "#changePassword_id")
private WebElement changePasswordOption;
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(){
log.info("Going to login page");
waitForElementToBeClickable(loginLnk).click();
......
......@@ -2,7 +2,10 @@ package pages.components.baseComponents;
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.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
......@@ -11,235 +14,220 @@ import utils.PROPERTIES;
public class PageComponent {
protected WebDriver driver;
protected WebDriverWait wait;
protected Logger log = Logger.getLogger(this.getClass());
public PageComponent(WebDriver driver) {
this.driver = driver;
this.wait = new WebDriverWait(this.driver, PROPERTIES.TIMEOUT);
}
public WebElement waitForElementToBeClickable(WebElement element) {
return wait.until(ExpectedConditions.elementToBeClickable(element));
}
public WebElement waitForElementToBeVisible(WebElement element) {
return wait.until(ExpectedConditions.visibilityOf(element));
}
public WebElement waitForElementToBeVisible(By elementSelector) {
return wait.until(ExpectedConditions.visibilityOfElementLocated(elementSelector));
}
public void waitForElementToBeEnabled(WebElement element) {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0;
while ((null != element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300;
waitForXMillis(300);
}
}
public void waitForElementToBeDisabled(WebElement element) {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0;
while ((null == element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300;
waitForXMillis(300);
}
}
public void waitForElementToBeGone(WebElement element) {
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
try {
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 waitForElementToBeGone(By locator) {
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
try {
myWait.until(ExpectedConditions.visibilityOfElementLocated(locator));
} catch (Exception e) {
return;
}
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) {
boolean displayed = true;
try {
displayed = driver.findElement(locator).isDisplayed();
} catch (Exception e) {
return;
}
if (!displayed) {
return;
}
waitForXMillis(500);
waitTime = waitTime - 500;
}
}
public void waitForNumberOfWindowsToBe(int noOfWindows) {
try {
wait.until(numberOfWindowsToBe(noOfWindows));
} catch (Exception e) {
}
}
public void clearAndFillInput(WebElement element, String toFill) {
waitForElementToBeVisible(element).clear();
log.info("cleared input");
waitForElementToBeEnabled(element);
element.sendKeys(toFill);
log.info("filled in text " + toFill);
}
public void clickVoidSpace() {
log.info("clicking void");
try {
waitForXMillis(500);
((JavascriptExecutor) driver).executeScript("document.querySelector('[class*=\"overlay-backdrop\"]').click()");
waitForXMillis(500);
} catch (Exception e) {
}
waitForXMillis(500);
}
private ExpectedCondition<Boolean> numberOfWindowsToBe(final int numberOfWindows) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
driver.getWindowHandles();
return driver.getWindowHandles().size() == numberOfWindows;
}
};
}
public void waitForXMillis(Integer millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
log.error("EXCEPTION: ", e);
}
}
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 waitForElementToBe(WebElement element) {
wait.until(new ExpectedCondition<Boolean>() {
@Override
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 waitForElementToHaveText(WebElement element) {
wait.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return !element.getText().trim().isEmpty();
}
});
}
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");
try {
waitForElementToBe(element);
return element.isDisplayed();
} catch (Exception e) { }
return false;
}
public boolean isEnabled(WebElement element){
log.info("checking if element is enabled");
try {
waitForElementToBeEnabled(element);
} catch (Exception e) {
return false;
}
return element.isEnabled();
}
public boolean isDisabled(WebElement element){
log.info("checking if element is disabled");
try {
waitForElementToBeDisabled(element);
} catch (Exception e) {
return false;
}
return true;
}
protected By loadingBar = By.className("mat-ripple-element");
public void waitForRowsToLoad() {
log.info("waiting for rows to load");
try {
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);
}
protected WebDriver driver;
protected WebDriverWait wait;
protected Logger log = Logger.getLogger(this.getClass());
protected By loadingBar = By.className("mat-ripple-element");
public PageComponent(WebDriver driver) {
this.driver = driver;
this.wait = new WebDriverWait(this.driver, PROPERTIES.TIMEOUT);
}
public WebElement waitForElementToBeClickable(WebElement element) {
return wait.until(ExpectedConditions.elementToBeClickable(element));
}
public WebElement waitForElementToBeVisible(WebElement element) {
return wait.until(ExpectedConditions.visibilityOf(element));
}
public WebElement waitForElementToBeVisible(By elementSelector) {
return wait.until(ExpectedConditions.visibilityOfElementLocated(elementSelector));
}
public void waitForElementToBeEnabled(WebElement element) {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0;
while ((null != element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300;
waitForXMillis(300);
}
}
public void waitForElementToBeDisabled(WebElement element) {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0;
while ((null == element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300;
waitForXMillis(300);
}
}
public void waitForElementToBeGone(WebElement element) {
WebDriverWait myWait = new WebDriverWait(driver, 1);
try {
myWait.until(ExpectedConditions.visibilityOf(element));
myWait.until(ExpectedConditions.invisibilityOf(element));
} catch (Exception e) {
return;
}
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) {
try {
if (!element.isDisplayed()) {
return;
}
} catch (Exception e) {
return;
}
waitForXMillis(500);
waitTime = waitTime - 500;
}
}
public void waitForElementToBeGone(By locator) {
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
try {
myWait.until(ExpectedConditions.visibilityOfElementLocated(locator));
} catch (Exception e) {
return;
}
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) {
boolean displayed = true;
try {
displayed = driver.findElement(locator).isDisplayed();
} catch (Exception e) {
return;
}
if (!displayed) {
return;
}
waitForXMillis(500);
waitTime = waitTime - 500;
}
}
public void waitForNumberOfWindowsToBe(int noOfWindows) {
try {
wait.until(numberOfWindowsToBe(noOfWindows));
} catch (Exception e) {
}
}
public void clearAndFillInput(WebElement element, String toFill) {
log.info("clearing input");
waitForElementToBeEnabled(element);
element.clear();
element.sendKeys(toFill);
log.info("filled in text " + toFill);
}
public void clickVoidSpace() {
log.info("clicking void");
try {
waitForXMillis(500);
((JavascriptExecutor) driver).executeScript("document.querySelector('[class*=\"overlay-backdrop\"]').click()");
waitForXMillis(500);
} catch (Exception e) {
}
waitForXMillis(500);
}
private ExpectedCondition<Boolean> numberOfWindowsToBe(final int numberOfWindows) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
driver.getWindowHandles();
return driver.getWindowHandles().size() == numberOfWindows;
}
};
}
public void waitForXMillis(Integer millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
log.error("EXCEPTION: ", e);
}
}
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 waitForElementToBe(WebElement element) {
wait.until(new ExpectedCondition<Boolean>() {
@Override
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 waitForElementToHaveText(WebElement element) {
wait.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return !element.getText().trim().isEmpty();
}
});
}
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");
try {
waitForElementToBe(element);
return element.isDisplayed();
} catch (Exception e) {
}
return false;
}
public boolean isEnabled(WebElement element) {
log.info("checking if element is enabled");
try {
waitForElementToBeEnabled(element);
} catch (Exception e) {
return false;
}
return element.isEnabled();
}
public boolean isDisabled(WebElement element) {
log.info("checking if element is disabled");
try {
waitForElementToBeDisabled(element);
} catch (Exception e) {
return false;
}
return true;
}
public void waitForRowsToLoad() {
log.info("waiting for rows to load");
try {
waitForElementToBeGone(loadingBar);
} catch (Exception e) {
}
waitForXMillis(500);
}
}
......
package pages.components.grid;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
......@@ -8,67 +7,65 @@ import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.DefaultElementLocatorFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import pages.components.baseComponents.PageComponent;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
public class BasicGrid extends PageComponent {
public BasicGrid(WebDriver driver, WebElement container) {
super(driver);
log.info("Loading basic grid");
waitForRowsToLoad();
PageFactory.initElements( new DefaultElementLocatorFactory(container) , this);
@FindBy(css = "datatable-header div.datatable-row-center datatable-header-cell")
protected List<WebElement> gridHeaders;
@FindBy(css = "datatable-body-row > div.datatable-row-center.datatable-row-group")
protected List<WebElement> gridRows;
protected ArrayList<String> headerTxt = new ArrayList<String>();
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")
protected List<WebElement> gridRows;
protected ArrayList<String> headerTxt = new ArrayList<String>();
public void selectRow(int rowNumber){
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 void selectRow(int rowNumber) {
log.info("selecting row with number ... " + rowNumber);
if (rowNumber >= gridRows.size()) {
return;
}
gridRows.get(rowNumber).click();
waitForXMillis(500);
}
public int getColumnsNo(){
log.info("getting number of columns");
return gridHeaders.size();
}
public void doubleClickRow(int rowNumber) {
public int getRowsNo(){
return gridRows.size();
}
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 void scrollRow(int index) {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].scrollIntoView();",gridRows.get(index));
waitForXMillis(500);
}
public int getColumnsNo() {
log.info("getting number of columns");
return gridHeaders.size();
}
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 {
}
public String getMessage() {
return message.replaceAll("×", "").trim();
System.out.println("message = " + message);
return message.replaceAll("×", "").trim();
}
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 {
@FindBy(id = "searchTable")
private WebElement searchTable;
@FindBy(id = "okButton")
private WebElement okButton;
@FindBy(id = "cancelButton")
private WebElement cancelButton;
......@@ -101,6 +104,11 @@ public class EditPage extends SMPPage {
waitForElementToBeClickable(cancelButton).click();
return new ConfirmationDialog(driver);
}
public ConfirmationDialog clickOk() {
log.info("canceling ...");
waitForElementToBeClickable(okButton).click();
return new ConfirmationDialog(driver);
}
public void clickDelete() {
log.info("deleting ...");
......
......@@ -33,10 +33,10 @@ public class ServiceGroupPopup extends PageComponent {
private WebElement domainsPanelContainer;
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;
@FindBy(css = "mat-dialog-actions > div > button:nth-child(2)")
@FindBy(css = "mat-dialog-actions button:nth-child(2)")
private WebElement cancelButton;
@FindBy(css = "#participantIdentifier_id")
......@@ -57,7 +57,7 @@ public class ServiceGroupPopup extends PageComponent {
@FindBy(css = "mat-card-content > mat-toolbar > mat-toolbar-row > button:nth-child(3)")
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;
......@@ -69,6 +69,14 @@ public class ServiceGroupPopup extends PageComponent {
log.info("is cancel button visible");
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(){
log.info("is Extension Area Editable");
......@@ -114,7 +122,7 @@ public class ServiceGroupPopup extends PageComponent {
public void clickCancel(){
log.info("click cancel..");
waitForElementToBeClickable(cancelButton).click();
waitForElementToBeGone(okButton);
waitForElementToBeGone(cancelButton);
}
public void fillForm(String identifier, String scheme, List<String> owners, List<String> domains, String extension){
......
......@@ -5,146 +5,233 @@ 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.ConfirmationDialog;
import pages.components.GenericSelect;
import pages.components.baseComponents.PageComponent;
public class UserPopup extends PageComponent {
public UserPopup(WebDriver driver) {
super(driver);
PageFactory.initElements(driver, this);
rolesSelect = new GenericSelect(driver, rolesSelectContainer);
}
public GenericSelect rolesSelect;
@FindBy(id = "userDetailsToggle_id")
WebElement userDetailsToggle;
@FindBy(css = "#active_id > label > div > div")
WebElement activeToggle;
@FindBy(id = "userDetailsToggle_id")
WebElement userDetailsToggle;
@FindBy(id = "username_id")
WebElement userNameInput;
@FindBy(css = "#active_id > label > div > div")
WebElement activeToggle;
@FindBy(id = "emailAddress_id")
WebElement emailInput;
@FindBy(id = "username_id")
WebElement userNameInput;
@FindBy(id = "np_id")
WebElement newPasswordInput;
@FindBy(id = "emailAddress_id")
WebElement emailInput;
@SuppressWarnings("SpellCheckingInspection")
@FindBy(id = "cnp_id")
WebElement confirmationInput;
@FindBy(id = "password_id")
WebElement passwordInput;
@FindBy(css = "input#cp_id")
WebElement adminPassInput;
@SuppressWarnings("SpellCheckingInspection")
@FindBy(id = "usernameconfirmation_id")
WebElement confirmationInput;
@FindBy(css = "mat-form-field.username> div > div.mat-form-field-flex > div > div")
WebElement usernameValidationError;
@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-content > table > tr > td > button:nth-child(1)")
WebElement okBtn;
@FindBy(css = "mat-dialog-content > table > tr > td > button:nth-child(2)")
WebElement cancelBtn;
@FindBy(css = "#role_id")
WebElement rolesSelectContainer;
public GenericSelect rolesSelect;
public boolean isOKButtonActive() {
return isEnabled(okBtn);
}
public boolean isCancelButtonActive() {
return isEnabled(cancelBtn);
}
public void fillData(String user, String email, String role, String password, String confirmation) {
clearAndFillInput(userNameInput, user);
clearAndFillInput(emailInput, email);
clearAndFillInput(passwordInput, password);
clearAndFillInput(confirmationInput, confirmation);
GenericSelect rolesSelect = new GenericSelect(driver, rolesSelectContainer);
rolesSelect.selectOptionByText(role);
}
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 clickUserDetailsToggle() {
log.info("details toggle");
waitForElementToBeClickable(userDetailsToggle).click();
waitForElementToBeEnabled(userNameInput);
}
public void fillDetailsForm(String username, String pass, String confirmation) {
clearAndFillInput(userNameInput, username);
clearAndFillInput(passwordInput, pass);
clearAndFillInput(confirmationInput, confirmation);
emailInput.click();
}
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(".mat-form-field-infix > div.has-error"));
return passMatchValidationError.getText();
}
@FindBy(css = "smp-password-change-dialog .password-panel mat-form-field:nth-child(2) .mat-form-field-subscript-wrapper mat-error")
WebElement passValidationError;
@FindBy(css = "mat-form-field.password-confirmation > div > div.mat-form-field-flex > div > div")
WebElement passConfirmationValidationError;
@FindBy(css = ".ng-trigger.ng-trigger-transitionMessages.ng-star-inserted > mat-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;
@FindBy(css = "#role_id")
WebElement rolesSelectContainer;
public UserPopup(WebDriver driver) {
super(driver);
PageFactory.initElements(driver, this);
rolesSelect = new GenericSelect(driver, rolesSelectContainer);
}
public boolean isAdminPasswordInputEnable() {
boolean bool = adminPassInput.isEnabled();
return bool;
}
public boolean isNewPasswordInputEnable() {
boolean bool = newPasswordInput.isEnabled();
return bool;
}
public boolean isConfirmPasswordInputEnable() {
boolean bool = confirmationInput.isEnabled();
return bool;
}
public boolean isOKButtonActive() {
return isEnabled(okBtn);
}
public boolean isChangePasswordActive() {
return isEnabled(passChangedClose);
}
public boolean isChangePasswordButtonActive() {
return isEnabled(changedPassword);
}
public boolean isCancelButtonActive() {
return isEnabled(cancelBtn);
}
public void fillData(String user, String email, String role, String password, String confirmation) {
clearAndFillInput(userNameInput, user);
clearAndFillInput(emailInput, email);
clearAndFillInput(newPasswordInput, password);
clearAndFillInput(confirmationInput, confirmation);
GenericSelect rolesSelect = new GenericSelect(driver, rolesSelectContainer);
rolesSelect.selectOptionByText(role);
}
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 clickUserDetailsToggle() {
log.info("details toggle");
waitForElementToBeClickable(userDetailsToggle).click();
waitForElementToBeEnabled(userNameInput);
}
//public void fillDetailsForm(String username, String pass, String confirmation)
public void fillDetailsForm(String username) {
clearAndFillInput(userNameInput, username);
//clearAndFillInput(passwordInput, pass);
//clearAndFillInput(confirmationInput, confirmation);
emailInput.click();
}
public void clickSetOrChangePassword() {
log.info("click change password");
waitForElementToBeClickable(changePassword);
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;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.util.ArrayList;
public class UserRowInfo{
private String username;
private String role;
private String certificate;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getCertificate() {
return certificate;
}
public void setCertificate(String certificate) {
this.certificate = certificate;
}
public class UserRowInfo {
private String username;
private String role;
private String certificate;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getCertificate() {
return certificate;
}
public void setCertificate(String certificate) {
this.certificate = certificate;
}
}
package pages.users;
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 org.openqa.selenium.support.ui.ExpectedConditions;
import pages.components.ConfirmationDialog;
import pages.components.baseComponents.PaginationControls;
import pages.components.baseComponents.SMPPage;
import pages.components.grid.BasicGrid;
import utils.PROPERTIES;
import java.util.List;
public class UsersPage extends SMPPage {
public UsersPage(WebDriver driver) {
super(driver);
this.pageHeader.waitForTitleToBe("Users");
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
}
public PaginationControls pagination = new PaginationControls(driver);
@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() {
log.info("checking Users page is loaded");
return isVisible(cancelBtn)
&& isVisible(saveBtn)
&& isVisible(newBtn)
&& isEnabled(newBtn)
&& isVisible(editBtn)
&& isVisible(deleteBtn);
}
public boolean isCancelButtonEnabled() {
log.info("cancel button");
return isEnabled(cancelBtn);
}
public boolean isSaveButtonEnabled() {
log.info("save button");
return isEnabled(saveBtn);
}
public boolean isDeleteButtonEnabled() {
waitForXMillis(200);
log.info("delete button");
return isEnabled(deleteBtn);
}
public ConfirmationDialog clickCancel() {
log.info("click cancel button");
waitForElementToBeClickable(cancelBtn).click();
return new ConfirmationDialog(driver);
}
public ConfirmationDialog clickSave() {
log.info("click save button");
waitForElementToBeClickable(saveBtn).click();
return new ConfirmationDialog(driver);
}
public void clickDelete() {
log.info("click delete button");
waitForElementToBeClickable(deleteBtn).click();
waitForRowsToLoad();
}
public UserPopup clickNew() {
log.info("click new button");
waitForElementToBeClickable(newBtn).click();
return new UserPopup(driver);
}
public UserPopup clickEdit() {
log.info("click edit button");
waitForElementToBeClickable(editBtn).click();
return new UserPopup(driver);
}
public UsersGrid grid() {
return new UsersGrid(driver, userTableContainer);
}
public void createUser() {
log.info("create user");
waitForElementToBeClickable(newBtn).click();
UserPopup popup = new UserPopup(driver);
popup.clickOK();
}
public boolean isNewButtonEnabled() {
try {
return newBtn.isEnabled();
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public PaginationControls pagination = new PaginationControls(driver);
@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 UsersPage(WebDriver driver) {
super(driver);
this.pageHeader.waitForTitleToBe("Users");
PageFactory.initElements(new AjaxElementLocatorFactory(driver, PROPERTIES.TIMEOUT), this);
}
public boolean isLoaded() {
log.info("checking Users page is loaded");
return isVisible(cancelBtn)
&& isVisible(saveBtn)
&& isVisible(newBtn)
&& isEnabled(newBtn)
&& isVisible(editBtn)
&& isVisible(deleteBtn);
}
public boolean isCancelButtonEnabled() {
log.info("cancel button");
return isEnabled(cancelBtn);
}
public boolean isSaveButtonEnabled() {
log.info("save button");
return isEnabled(saveBtn);
}
public boolean isDeleteButtonEnabled() {
waitForXMillis(200);
log.info("delete button");
return isEnabled(deleteBtn);
}
public ConfirmationDialog clickCancel() {
log.info("click cancel button");
waitForElementToBeClickable(cancelBtn).click();
return new ConfirmationDialog(driver);
}
public ConfirmationDialog clickSave() {
log.info("click save button");
waitForElementToBeClickable(saveBtn).click();
return new ConfirmationDialog(driver);
}
public void clickDelete() {
log.info("click delete button");
waitForElementToBeClickable(deleteBtn).click();
waitForRowsToLoad();
}
public UserPopup clickNew() {
log.info("click new button");
waitForElementToBeClickable(newBtn).click();
return new UserPopup(driver);
}
public UserPopup clickEdit() {
log.info("click edit button");
waitForElementToBeClickable(editBtn).click();
return new UserPopup(driver);
}
public UsersGrid grid() {
return new UsersGrid(driver, userTableContainer);
}
public void createUser() {
log.info("create user");
waitForElementToBeClickable(newBtn).click();
UserPopup popup = new UserPopup(driver);
popup.clickOK();
}
public boolean isNewButtonEnabled() {
try {
return newBtn.isEnabled();
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
package utils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class DriverManager {
......@@ -24,24 +20,16 @@ public class DriverManager {
// return driver;
// }
public static WebDriver getDriver(){
System.setProperty(FirefoxDriver.SystemProperty.DRIVER_USE_MARIONETTE,"true");
// System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE,"C:\\temp\\logs.txt");
FirefoxOptions options = new FirefoxOptions();
FirefoxProfile profile= new FirefoxProfile();
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);
public static WebDriver getDriver() {
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
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