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; 018 019import org.nuxeo.functionaltests.fragment.GadgetsContainerFragment; 020import org.nuxeo.functionaltests.pages.tabs.SummaryTabSubPage; 021import org.openqa.selenium.By; 022import org.openqa.selenium.WebDriver; 023import org.openqa.selenium.WebElement; 024import org.openqa.selenium.support.FindBy; 025 026/** 027 * @since 5.7 028 */ 029public class UserHomePage extends AbstractPage { 030 031 // not required: when navigating to home, we could be on another tab than 032 // dashboard 033 @FindBy(id = GadgetsContainerFragment.GADGETS_CONTAINER_ID) 034 public WebElement gadgetsContainer; 035 036 protected GadgetsContainerFragment gadgetsFragment; 037 038 public UserHomePage(WebDriver driver) { 039 super(driver); 040 } 041 042 protected GadgetsContainerFragment getGadgetsFragment() { 043 if (gadgetsFragment == null) { 044 gadgetsFragment = getWebFragment(gadgetsContainer, GadgetsContainerFragment.class); 045 } 046 return gadgetsFragment; 047 } 048 049 public boolean isTaskGadgetLoaded() { 050 return getGadgetsFragment().isGadgetLoaded("My Tasks"); 051 } 052 053 public SummaryTabSubPage redirectToTask(String taskTitle) { 054 WebDriver driver = getGadgetsFragment().switchToFrame("My Tasks"); 055 driver.findElement(By.linkText(taskTitle)).click(); 056 return new SummaryTabSubPage(driver); 057 } 058 059 public boolean isTaskGadgetEmpty() { 060 return getGadgetsFragment().isTaskGadgetEmpty("My Tasks"); 061 } 062 063 /** 064 * @since 5.8 065 */ 066 public WorkflowHomePage getWorkflowHomePage() { 067 findElementWithTimeout(By.linkText("Workflow")).click(); 068 return asPage(WorkflowHomePage.class); 069 } 070 071 public UserHomePage goToDashboard() { 072 findElementWithTimeout(By.linkText("Dashboard")).click(); 073 return this; 074 } 075 076 public ProfilePage goToProfile() { 077 findElementWithTimeout(By.linkText("Profile")).click(); 078 return asPage(ProfilePage.class); 079 } 080 081}