001/*
002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Sun Seng David TAN
016 *     Florent Guillaume
017 */
018package org.nuxeo.functionaltests.pages.usermanagement.compat;
019
020import org.nuxeo.functionaltests.Required;
021import org.openqa.selenium.By;
022import org.openqa.selenium.NoSuchElementException;
023import org.openqa.selenium.WebDriver;
024import org.openqa.selenium.WebElement;
025import org.openqa.selenium.support.FindBy;
026
027/**
028 * Nuxeo DM user management page.
029 */
030public class UserCreationFormPage extends UsersGroupsBasePage {
031
032    @Required
033    @FindBy(id = "createUser:nxl_user:nxw_username")
034    WebElement usernameInput;
035
036    @Required
037    @FindBy(id = "createUser:nxl_user:nxw_firstname")
038    WebElement firstnameInput;
039
040    @Required
041    @FindBy(id = "createUser:nxl_user:nxw_lastname")
042    WebElement lastnameInput;
043
044    @Required
045    @FindBy(id = "createUser:nxl_user:nxw_company")
046    WebElement companyInput;
047
048    @Required
049    @FindBy(id = "createUser:nxl_user:nxw_email")
050    WebElement emailInput;
051
052    @Required
053    @FindBy(id = "createUser:nxl_user:nxw_firstPassword")
054    WebElement firstPasswordInput;
055
056    @Required
057    @FindBy(id = "createUser:nxl_user:nxw_secondPassword")
058    WebElement secondPasswordInput;
059
060    @Required
061    @FindBy(id = "createUser:nxl_user:nxw_groups_suggest")
062    WebElement groupInput;
063
064    @Required
065    @FindBy(id = "createUser:button_create")
066    WebElement createButton;
067
068    public UserCreationFormPage(WebDriver driver) {
069        super(driver);
070    }
071
072    public UsersGroupsBasePage createUser(String username, String firstname, String lastname, String company,
073            String email, String password, String group) throws NoSuchElementException {
074        usernameInput.sendKeys(username);
075        firstnameInput.sendKeys(firstname);
076        lastnameInput.sendKeys(lastname);
077        companyInput.sendKeys(company);
078        emailInput.sendKeys(email);
079        firstPasswordInput.sendKeys(password);
080        secondPasswordInput.sendKeys(password);
081        groupInput.sendKeys(group);
082        WebElement ajaxUserListElement = findElementWithTimeout(By.xpath("//table[@id='createUser:nxl_user:nxw_groups_suggestionBox:suggest']/tbody/tr[1]/td[2]"));
083        ajaxUserListElement.click();
084        createButton.click();
085        return asPage(UsersGroupsBasePage.class);
086    }
087
088}