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 <stan@nuxeo.com>
018 *     Antoine Taillefer
019 */
020package org.nuxeo.functionaltests.pages.tabs;
021
022import org.nuxeo.functionaltests.Required;
023import org.nuxeo.functionaltests.pages.AbstractPage;
024import org.nuxeo.functionaltests.pages.DocumentBasePage;
025import org.openqa.selenium.By;
026import org.openqa.selenium.WebDriver;
027import org.openqa.selenium.WebElement;
028import org.openqa.selenium.support.FindBy;
029
030/**
031 * @author Sun Seng David TAN <stan@nuxeo.com>
032 */
033public class EditTabSubPage extends AbstractPage {
034
035    public static final String MAJOR_VERSION_INCREMENT_VALUE = "ACTION_INCREMENT_MAJOR";
036
037    public static final String MINOR_VERSION_INCREMENT_VALUE = "ACTION_INCREMENT_MINOR";
038
039    @FindBy(id = "document_edit:nxl_heading:nxw_title")
040    WebElement titleInputText;
041
042    @FindBy(id = "document_edit:nxl_heading:nxw_description")
043    WebElement descriptionInputText;
044
045    @Required
046    @FindBy(id = "document_edit:nxw_documentEditButtons_EDIT_CURRENT_DOCUMENT")
047    WebElement save;
048
049    public EditTabSubPage(WebDriver driver) {
050        super(driver);
051    }
052
053    /**
054     * By default
055     *
056     * @param title
057     * @param description
058     */
059    public DocumentBasePage edit(String title, String description, String versionIncrementLabel) {
060
061        if (title != null) {
062            titleInputText.clear();
063            titleInputText.sendKeys(title);
064        }
065        if (description != null) {
066            descriptionInputText.clear();
067            descriptionInputText.sendKeys(description);
068        }
069        if (versionIncrementLabel != null) {
070            WebElement versionIncrementRadio = driver.findElement(By.xpath("//input[@value=\"" + versionIncrementLabel
071                    + "\"]"));
072            versionIncrementRadio.click();
073        }
074
075        save.click();
076
077        return asPage(DocumentBasePage.class);
078    }
079
080    /**
081     * Save the modifications.
082     *
083     * @since 5.7.3
084     */
085    public DocumentBasePage save() {
086        save.click();
087        return asPage(DocumentBasePage.class);
088    }
089
090}