Newer
Older

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

Mihai BOZ
committed
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;
import pages.userSettings.SuccesfullPasswordChangedPopup;

Mihai BOZ
committed
import java.util.ArrayList;
import java.util.List;
/**
* Page object for the Set/change password dialog. This contains the locators of the page and the methods for the behaviour of the page
*/

Mihai BOZ
committed
public class SetChangePasswordDialog extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(SetChangePasswordDialog.class);
@FindBy(css = ".smp-field-error")
List<WebElement> fieldsError;
@FindBy(id = "cp_id")
private WebElement currentPasswordInput;
@FindBy(id = "np_id")
private WebElement newPasswordInput;
@FindBy(id = "cnp_id")
private WebElement confirmationPasswordInput;

Mihai BOZ
committed
@FindBy(id = "changeCurrentUserPasswordButton")

Mihai BOZ
committed
private WebElement setPasswordBtn;
public SetChangePasswordDialog(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);

Mihai BOZ
committed
}
public void fillChangePassword(String currentPassword, String newPassword) throws Exception {

Mihai BOZ
committed
LOG.info("Set new password");
weToDInput(currentPasswordInput).fill(currentPassword);
weToDInput(newPasswordInput).fill(newPassword, true);
weToDInput(confirmationPasswordInput).fill(newPassword, true);

Mihai BOZ
committed
//wait.forElementToBeClickable(setPasswordBtn);
if (weToDButton(setPasswordBtn).isEnabled()) {
weToDButton(setPasswordBtn).click();
return new DomiSMPPage(driver);
} else {
return null;
}

Mihai BOZ
committed
}
public List<String> getFieldErrorMessage() {
ArrayList<String> fieldErrors = new ArrayList<>();