001/* 002 * (C) Copyright 2013 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 * Mariana Cedica 016 */ 017package org.nuxeo.functionaltests.pages.tabs; 018 019/** 020 * @since 5.7 021 */ 022import java.text.DateFormat; 023import java.util.Date; 024import java.util.Locale; 025 026import org.junit.Assert; 027import org.nuxeo.functionaltests.forms.Select2WidgetElement; 028import org.nuxeo.functionaltests.pages.DocumentBasePage; 029import org.openqa.selenium.By; 030import org.openqa.selenium.WebDriver; 031import org.openqa.selenium.WebElement; 032import org.openqa.selenium.support.FindBy; 033 034public class WorkflowTabSubPage extends DocumentBasePage { 035 036 @FindBy(xpath = "//form[contains(@id, 'nxl_tasks_form')]") 037 public WebElement workflowTasksForm; 038 039 @FindBy(xpath = "//select[contains(@id, 'nxw_validationOrReview')]") 040 public WebElement reviewSelector; 041 042 public WorkflowTabSubPage(WebDriver driver) { 043 super(driver); 044 } 045 046 /** 047 * Add reviewer in default serial workflow 048 */ 049 public void addWorkflowReviewer(final String username) { 050 Select2WidgetElement particpants = new Select2WidgetElement(driver, 051 driver.findElement(By.xpath("//div[contains(@id, 'nxw_participants_select2')]")), true); 052 particpants.selectValue(username); 053 selectItemInDropDownMenu(reviewSelector, "Simple Review"); 054 } 055 056 /** 057 * Add reviewer in default parallel workflow 058 * 059 * @since 5.9.1 060 */ 061 public void addParallelWorkflowReviewer(String user) { 062 Select2WidgetElement particpants = new Select2WidgetElement(driver, 063 driver.findElement(By.xpath("//div[contains(@id, 'nxw_participants_select2')]")), true); 064 particpants.selectValue(user); 065 } 066 067 /** 068 * @since 5.9.1 069 */ 070 public void addParallelWorkflowEndDate() { 071 DateFormat sdf = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH); 072 WebElement endDate = driver.findElement((By.xpath("//input[contains(@id, 'nxw_end_dateInputDate')]"))); 073 endDate.sendKeys(sdf.format(new Date())); 074 // validate input date 075 Assert.assertTrue(endDate.getAttribute("value").equals(sdf.format(new Date()))); 076 } 077 078 public void showGraphView() { 079 findElementAndWaitUntilEnabled(By.linkText("Show Graph View")).click(); 080 } 081 082 public void closeGraphView() { 083 findElementAndWaitUntilEnabled(By.id("fancybox-close")).click(); 084 } 085 086 public void startWorkflow() { 087 findElementAndWaitUntilEnabled(By.xpath("//input[@value='Start the Review']")).click(); 088 } 089 090 /** 091 * @since 5.9.1 092 */ 093 public void endTask(String taskName, String comment) { 094 findElementAndWaitUntilEnabled(By.tagName("textarea")).sendKeys(comment); 095 findElementAndWaitUntilEnabled(By.xpath(String.format("//input[@value='%s']", taskName))).click(); 096 } 097 098 public void endTask(String taskName) { 099 findElementAndWaitUntilEnabled(By.xpath(String.format("//input[@value='%s']", taskName))).click(); 100 } 101 102 /** 103 * @since 5.8 104 */ 105 public WebElement getTaskLayoutNode() { 106 return findElementWithTimeout(By.xpath("//div[starts-with(@id, 'nxl_current_route_layout:nxw_current_route_user_tasks_panel')]")); 107 } 108 109 @Override 110 public SummaryTabSubPage getSummaryTab() { 111 clickOnDocumentTabLink(summaryTabLink); 112 return asPage(SummaryTabSubPage.class); 113 } 114}