001/*
002 * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Thomas Roger
018 *
019 */
020package org.nuxeo.functionaltests.pages.profile;
021
022import org.nuxeo.functionaltests.Required;
023import org.nuxeo.functionaltests.pages.AbstractPage;
024import org.openqa.selenium.WebDriver;
025import org.openqa.selenium.WebElement;
026import org.openqa.selenium.support.FindBy;
027
028/**
029 * Change password sub tab page (From profile page)
030 *
031 * @since 7.3
032 */
033public class OwnUserChangePasswordFormPage extends AbstractPage {
034
035    @Required
036    @FindBy(id = "editUserPassword:nxl_profile_password:nxw_profilePasswordMatcher_firstPassword")
037    WebElement firstPasswordInput;
038
039    @Required
040    @FindBy(id = "editUserPassword:nxl_profile_password:nxw_profilePasswordMatcher_secondPassword")
041    WebElement secondPasswordInput;
042
043    @Required
044    @FindBy(id = "editUserPassword:nxl_profile_password:nxw_profilePasswordMatcher_oldPassword")
045    WebElement oldPasswordInput;
046
047    @Required
048    @FindBy(xpath = "//input[@value=\"Save\"]")
049    WebElement saveButton;
050
051    @FindBy(id = "editUserPassword")
052    WebElement form;
053
054    public OwnUserChangePasswordFormPage(WebDriver driver) {
055        super(driver);
056    }
057
058    public OwnUserChangePasswordFormPage changePassword(String password) {
059        return changePassword(password, password);
060    }
061
062    public OwnUserChangePasswordFormPage changePassword(String oldPassword, String password) {
063        return changePassword(oldPassword, password, password);
064    }
065
066    /**
067     * @since 8.3
068     */
069    public OwnUserChangePasswordFormPage changePassword(String oldPassword, String password1, String password2) {
070        firstPasswordInput.clear();
071        firstPasswordInput.sendKeys(password1);
072        secondPasswordInput.clear();
073        secondPasswordInput.sendKeys(password2);
074        oldPasswordInput.clear();
075        oldPasswordInput.sendKeys(oldPassword);
076        saveButton.click();
077        return asPage(OwnUserChangePasswordFormPage.class);
078    }
079
080    /**
081     * @since 8.3
082     */
083    public WebElement getForm() {
084        return form;
085    }
086
087}