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 <[email protected]> 018 * Antoine Taillefer 019 */ 020package org.nuxeo.functionaltests.pages.tabs; 021 022import org.nuxeo.functionaltests.Locator; 023import org.nuxeo.functionaltests.Required; 024import org.nuxeo.functionaltests.pages.AbstractPage; 025import org.nuxeo.functionaltests.pages.DocumentBasePage; 026import org.openqa.selenium.By; 027import org.openqa.selenium.WebDriver; 028import org.openqa.selenium.WebElement; 029import org.openqa.selenium.support.FindBy; 030 031/** 032 * @author Sun Seng David TAN <[email protected]> 033 */ 034public class EditTabSubPage extends AbstractPage { 035 036 public static final String MAJOR_VERSION_INCREMENT_VALUE = "ACTION_INCREMENT_MAJOR"; 037 038 public static final String MINOR_VERSION_INCREMENT_VALUE = "ACTION_INCREMENT_MINOR"; 039 040 @FindBy(id = "document_edit:nxl_heading:nxw_title") 041 WebElement titleInputText; 042 043 @FindBy(id = "document_edit:nxl_heading:nxw_description") 044 WebElement descriptionInputText; 045 046 @Required 047 @FindBy(id = "document_edit:nxw_documentEditButtons_EDIT_CURRENT_DOCUMENT") 048 WebElement save; 049 050 public EditTabSubPage(WebDriver driver) { 051 super(driver); 052 } 053 054 /** 055 * By default 056 * 057 * @param title 058 * @param description 059 */ 060 public DocumentBasePage edit(String title, String description, String versionIncrementLabel) { 061 062 if (title != null) { 063 titleInputText.clear(); 064 titleInputText.sendKeys(title); 065 } 066 if (description != null) { 067 descriptionInputText.clear(); 068 descriptionInputText.sendKeys(description); 069 } 070 if (versionIncrementLabel != null) { 071 WebElement versionIncrementRadio = driver.findElement( 072 By.xpath("//input[@value=\"" + versionIncrementLabel + "\"]")); 073 Locator.waitUntilEnabledAndClick(versionIncrementRadio); 074 } 075 076 return save(); 077 } 078 079 /** 080 * @since 8.3 081 */ 082 public String getTitle() { 083 return titleInputText.getAttribute("value"); 084 } 085 086 /** 087 * @since 8.3 088 */ 089 public EditTabSubPage setTitle(String title) { 090 titleInputText.clear(); 091 titleInputText.sendKeys(title); 092 return this; 093 } 094 095 /** 096 * @since 8.3 097 */ 098 public String getDescription() { 099 return descriptionInputText.getText(); 100 } 101 102 /** 103 * @since 8.3 104 */ 105 public EditTabSubPage setDescription(String description) { 106 descriptionInputText.clear(); 107 descriptionInputText.sendKeys(description); 108 return this; 109 } 110 111 /** 112 * Save the modifications. 113 * 114 * @since 5.7.3 115 */ 116 public DocumentBasePage save() { 117 Locator.waitUntilEnabledAndClick(save); 118 return asPage(DocumentBasePage.class); 119 } 120 121}