001/*
002 * (C) Copyright 2011 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 *     Sun Seng David TAN
018 *     Florent Guillaume
019 */
020package org.nuxeo.functionaltests.pages.usermanagement.compat;
021
022import org.nuxeo.functionaltests.Required;
023import org.openqa.selenium.By;
024import org.openqa.selenium.NoSuchElementException;
025import org.openqa.selenium.WebDriver;
026import org.openqa.selenium.WebElement;
027import org.openqa.selenium.support.FindBy;
028
029/**
030 * Nuxeo DM user management page.
031 */
032public class UserCreationFormPage extends UsersGroupsBasePage {
033
034    @Required
035    @FindBy(id = "createUser:nxl_user:nxw_username")
036    WebElement usernameInput;
037
038    @Required
039    @FindBy(id = "createUser:nxl_user:nxw_firstname")
040    WebElement firstnameInput;
041
042    @Required
043    @FindBy(id = "createUser:nxl_user:nxw_lastname")
044    WebElement lastnameInput;
045
046    @Required
047    @FindBy(id = "createUser:nxl_user:nxw_company")
048    WebElement companyInput;
049
050    @Required
051    @FindBy(id = "createUser:nxl_user:nxw_email")
052    WebElement emailInput;
053
054    @Required
055    @FindBy(id = "createUser:nxl_user:nxw_firstPassword")
056    WebElement firstPasswordInput;
057
058    @Required
059    @FindBy(id = "createUser:nxl_user:nxw_secondPassword")
060    WebElement secondPasswordInput;
061
062    @Required
063    @FindBy(id = "createUser:nxl_user:nxw_groups_suggest")
064    WebElement groupInput;
065
066    @Required
067    @FindBy(id = "createUser:button_create")
068    WebElement createButton;
069
070    public UserCreationFormPage(WebDriver driver) {
071        super(driver);
072    }
073
074    public UsersGroupsBasePage createUser(String username, String firstname, String lastname, String company,
075            String email, String password, String group) throws NoSuchElementException {
076        usernameInput.sendKeys(username);
077        firstnameInput.sendKeys(firstname);
078        lastnameInput.sendKeys(lastname);
079        companyInput.sendKeys(company);
080        emailInput.sendKeys(email);
081        firstPasswordInput.sendKeys(password);
082        secondPasswordInput.sendKeys(password);
083        groupInput.sendKeys(group);
084        WebElement ajaxUserListElement = findElementWithTimeout(
085                By.xpath("//table[@id='createUser:nxl_user:nxw_groups_suggestionBox:suggest']/tbody/tr[1]/td[2]"));
086        ajaxUserListElement.click();
087        createButton.click();
088        return asPage(UsersGroupsBasePage.class);
089    }
090
091}