001/*
002 * (C) Copyright 2014 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-2.1.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 *     <a href="mailto:grenard@nuxeo.com">Guillaume</a>
016 */
017package org.nuxeo.functionaltests.pages.forms;
018
019import org.nuxeo.functionaltests.Required;
020import org.nuxeo.functionaltests.pages.AbstractPage;
021import org.nuxeo.functionaltests.pages.DocumentBasePage;
022import org.openqa.selenium.WebDriver;
023import org.openqa.selenium.WebElement;
024import org.openqa.selenium.support.FindBy;
025
026/**
027 * @since 5.9.3
028 */
029public class DublinCoreCreationDocumentFormPage extends AbstractPage {
030
031    @Required
032    @FindBy(id = "document_create:nxl_heading:nxw_title")
033    public WebElement titleTextInput;
034
035    @FindBy(id = "document_create:nxl_heading:nxw_title_message")
036    public WebElement titleTextInputMessage;
037
038    @Required
039    @FindBy(id = "document_create:nxl_heading:nxw_description")
040    public WebElement descriptionTextInput;
041
042    @Required
043    @FindBy(id = "document_create:nxw_documentCreateButtons_CREATE_DOCUMENT")
044    public WebElement createButton;
045
046    public DublinCoreCreationDocumentFormPage(WebDriver driver) {
047        super(driver);
048    }
049
050    public void create() {
051        createButton.click();
052    }
053
054    protected void fillDublinCoreFieldsAndCreate(String title, String description) {
055        titleTextInput.sendKeys(title);
056        descriptionTextInput.sendKeys(description);
057        create();
058    }
059
060    public DocumentBasePage createDocument(String title, String description) {
061        fillDublinCoreFieldsAndCreate(title, description);
062        return asPage(DocumentBasePage.class);
063    }
064
065    /**
066     * @since 7.1
067     */
068    public String getTitleMessage() {
069        return titleTextInputMessage == null ? null : titleTextInputMessage.getText();
070    }
071
072}