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