001/* 002 * (C) Copyright 2011 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 * Thierry Delprat 016 */ 017package org.nuxeo.functionaltests.pages.admincenter; 018 019import java.util.ArrayList; 020import java.util.List; 021 022import org.nuxeo.functionaltests.Required; 023import org.nuxeo.functionaltests.pages.AbstractPage; 024import org.nuxeo.functionaltests.pages.DocumentBasePage; 025import org.nuxeo.functionaltests.pages.admincenter.monitoring.MonitoringPage; 026import org.nuxeo.functionaltests.pages.admincenter.usermanagement.UsersGroupsBasePage; 027import org.openqa.selenium.By; 028import org.openqa.selenium.WebDriver; 029import org.openqa.selenium.WebElement; 030import org.openqa.selenium.support.FindBy; 031 032public class AdminCenterBasePage extends AbstractPage { 033 034 // for ajax refresh wait until by adding required element 035 @Required 036 @FindBy(linkText = "System Information") 037 public WebElement systemInformationLink; 038 039 @FindBy(linkText = "Users & Groups") 040 public WebElement userAndGroupsLink; 041 042 @FindBy(linkText = "WORKSPACE") 043 public WebElement documentManagementLink; 044 045 @FindBy(linkText = "Update Center") 046 public WebElement updateCenterLink; 047 048 @FindBy(linkText = "Monitoring") 049 public WebElement monitoringLink; 050 051 @FindBy(linkText = "Nuxeo Online Services") 052 public WebElement nuxeoConnectLink; 053 054 @FindBy(linkText = "Vocabularies") 055 public WebElement vocabulariesLink; 056 057 @FindBy(linkText = "Workflow") 058 public WebElement worflowsLink; 059 060 public AdminCenterBasePage(WebDriver driver) { 061 super(driver); 062 } 063 064 public UsersGroupsBasePage getUsersGroupsHomePage() { 065 userAndGroupsLink.click(); 066 return asPage(UsersGroupsBasePage.class); 067 } 068 069 public ConnectHomePage getConnectHomePage() { 070 nuxeoConnectLink.click(); 071 return asPage(ConnectHomePage.class); 072 } 073 074 public UpdateCenterPage getUpdateCenterHomePage() { 075 updateCenterLink.click(); 076 return asPage(UpdateCenterPage.class); 077 } 078 079 public MonitoringPage getMonitoringPage() { 080 monitoringLink.click(); 081 return asPage(MonitoringPage.class); 082 } 083 084 public SystemHomePage getSystemHomePage() { 085 systemInformationLink.click(); 086 return asPage(SystemHomePage.class); 087 } 088 089 public VocabulariesPage getVocabulariesPage() { 090 vocabulariesLink.click(); 091 return asPage(VocabulariesPage.class); 092 } 093 094 public WorkflowsPage getWorkflowsPage() { 095 worflowsLink.click(); 096 return asPage(WorkflowsPage.class); 097 } 098 099 public String getSelectedSubTab() { 100 WebElement tab = findElementWithTimeout(By.xpath("//div[@id='nxw_adminCenterSubTabs_panel']//li[@class='selected']//a")); 101 if (tab != null) { 102 return tab.getText(); 103 } 104 return null; 105 } 106 107 public AdminCenterBasePage selectSubTab(String text) { 108 WebElement tab = findElementWithTimeout(By.xpath("//div[@id='nxw_adminCenterSubTabs_panel']//li/form/a/span[text()='" 109 + text + "']")); 110 if (tab != null) { 111 tab.click(); 112 return asPage(AdminCenterBasePage.class); 113 114 } 115 return null; 116 } 117 118 public List<String> getAvailableSubTabs() { 119 List<WebElement> elements = driver.findElements(By.xpath("//div[@id='nxw_adminCenterSubTabs_panel']//li/form/a/span")); 120 List<String> tabs = new ArrayList<String>(); 121 122 for (WebElement el : elements) { 123 tabs.add(el.getText()); 124 } 125 return tabs; 126 } 127 128 public DocumentBasePage exitAdminCenter() { 129 documentManagementLink.click(); 130 return asPage(DocumentBasePage.class); 131 } 132}