Newer
Older

Mihai BOZ
committed
package ddsl.dcomponents.commonComponents;
import ddsl.DomiSMPPage;

Mihai BOZ
committed
import ddsl.dcomponents.SetChangePasswordDialog;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Common component for user data used in Profile and Users page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class UserDataCommonComponent extends DomiSMPPage {
private final static Logger LOG = LoggerFactory.getLogger(UserDataCommonComponent.class);
@FindBy(id = "changePassword_id")
private WebElement setChangePasswordBtn;
@FindBy(id = "smpTheme_id")
private WebElement themeSel;
private WebElement localeSel;
@FindBy(id = "saveButton")
private WebElement saveBtn;
@FindBy(id = "emailAddress_id")
private WebElement emailAddressInput;
@FindBy(id = "fullName_id")
private WebElement fullNameInput;
@FindBy(id = "passwordUpdatedOn_id")
private WebElement lastSetLbl;
@FindBy(id = "passwordExpireOn_id")
private WebElement passwordExpiresOnLbl;
@FindBy(id = "sequentialLoginFailureCount_id")
private WebElement seqFailedAttempts;
@FindBy(id = "LastFailedAttempt_id")
private WebElement lastFailedAttempt;
@FindBy(id = "suspendedUtil_id")
private WebElement suspendedUntil;
public UserDataCommonComponent(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
public String getSelectedTheme() {
return weToDSelect(themeSel).getCurrentValue();
}
public String getSelectedLocale() {

Mihai BOZ
committed
return weToDSelect(localeSel).getCurrentValueAttribute("value");
}
public String getEmailAddress() {
return weToDInput(emailAddressInput).getText();
}
public String getFullName() {
return weToDInput(fullNameInput).getText();
}
public String getLastSetValue() {
return lastSetLbl.getAttribute("value");
}
public String getPasswordExpiresOnValue() {
return passwordExpiresOnLbl.getAttribute("value");
public String getSequenceFailedAttempts() {
return seqFailedAttempts.getAttribute("value");
}
public String getlastFailedAttempt() {
return lastFailedAttempt.getAttribute("value");
}
public String getsuspendedUntil() {
return suspendedUntil.getAttribute("value");
}
setChangePasswordBtn.click();
return new SetChangePasswordDialog(driver);
}
public String fillUserProfileData(String emailValue, String fullNameValue, String selectThemeValue, String localeValue) {
try {
if (!emailValue.isEmpty()) {
weToDInput(emailAddressInput).fill(emailValue);
}
if (!emailValue.isEmpty()) {
weToDInput(fullNameInput).fill(fullNameValue);
}

Mihai BOZ
committed
weToDSelect(themeSel).selectByVisibleText(selectThemeValue);
wait.forXMillis(data.getWaitTimeoutShortMilliseconds());

Mihai BOZ
committed
weToDSelect(localeSel).selectByVisibleText(localeValue);
} catch (Exception e) {
LOG.error("Cannot change User Profile Data ", e);
}
if (saveBtn.isEnabled()) {
saveBtn.click();
} else {
LOG.debug("Save button is " + saveBtn.isEnabled());
} catch (Exception e) {