package com.atlassian.webdriver.bitbucket.page;

import com.atlassian.pageobjects.elements.ElementBy;
import com.atlassian.pageobjects.elements.PageElement;

public class UserAccountPasswordPage extends BitbucketPage {
    @ElementBy(id = "currentPassword")
    private PageElement currentPassword;

    @ElementBy(id = "newPassword")
    private PageElement newPassword;

    @ElementBy(id = "confirmNewPassword")
    private PageElement confirmNewPassword;

    @ElementBy(id = "submit")
    private PageElement submitButton;

    @ElementBy(id = "cancel")
    private PageElement cancelLink;

    @ElementBy(cssSelector = ".aui-message.aui-message-success.success")
    private PageElement message;

    @Override
    public String getUrl() {
        return "/account/password";
    }

    public void setCurrentPassword(String password) {
        currentPassword.clear().type(password);
    }

    public void setNewPassword(String password) {
        newPassword.clear().type(password);
    }

    public void setConfirmNewPassword(String password) {
        confirmNewPassword.clear().type(password);
    }

    public String getMessageText() {
        return message.getText();
    }

    public UserAccountPasswordPage submit() {
        submitButton.click();
        return pageBinder.bind(UserAccountPasswordPage.class);
    }
}
