001/* 002 * (C) Copyright 2014 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 * <a href="mailto:grenard@nuxeo.com">Guillaume</a> 018 */ 019package org.nuxeo.functionaltests.pages; 020 021import org.nuxeo.functionaltests.AjaxRequestManager; 022import org.nuxeo.functionaltests.Required; 023import org.openqa.selenium.By; 024import org.openqa.selenium.WebDriver; 025import org.openqa.selenium.WebElement; 026import org.openqa.selenium.support.FindBy; 027 028/** 029 * @since 5.9.3 030 */ 031public class HomePage extends DocumentBasePage { 032 033 static final String COLLECTIONS_LABEL = "Collections"; 034 035 static final String SEARCHES_LABEL = "Searches"; 036 037 @Required 038 @FindBy(id = "nxw_homeTabs_panel") 039 protected WebElement menu; 040 041 public HomePage(WebDriver driver) { 042 super(driver); 043 } 044 045 public CollectionsPage goToCollections() { 046 goTo(COLLECTIONS_LABEL); 047 return asPage(CollectionsPage.class); 048 } 049 050 /** 051 * @since 8.1 052 */ 053 public HomePage goToSavedSearches() { 054 goTo(SEARCHES_LABEL); 055 return asPage(HomePage.class); 056 } 057 058 private void goTo(String label) { 059 if (useAjaxTabs()) { 060 AjaxRequestManager arm = new AjaxRequestManager(driver); 061 arm.begin(); 062 menu.findElement(By.linkText(label)).click(); 063 arm.end(); 064 } else { 065 menu.findElement(By.linkText(label)).click(); 066 } 067 } 068 069}