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