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 USERS_GROUPS_LABEL = "Users & Groups";
034
035    static final String COLLECTIONS_LABEL = "Collections";
036
037    static final String SEARCHES_LABEL = "Searches";
038
039    @Required
040    @FindBy(id = "nxw_homeTabs_panel")
041    protected WebElement menu;
042
043    public HomePage(WebDriver driver) {
044        super(driver);
045    }
046
047    /**
048     * @since 8.3
049     */
050    public UsersGroupsHomePage goToUsersGroupsHomePage() {
051        goTo(USERS_GROUPS_LABEL);
052        return asPage(UsersGroupsHomePage.class);
053    }
054
055    public CollectionsPage goToCollections() {
056        goTo(COLLECTIONS_LABEL);
057        return asPage(CollectionsPage.class);
058    }
059
060    /**
061     * @since 8.1
062     */
063    public HomePage goToSavedSearches() {
064        goTo(SEARCHES_LABEL);
065        return asPage(HomePage.class);
066    }
067
068    /**
069     * @since 8.3
070     */
071    public void goTo(String tabLabel) {
072        if (useAjaxTabs()) {
073            AjaxRequestManager arm = new AjaxRequestManager(driver);
074            arm.begin();
075            menu.findElement(By.linkText(tabLabel)).click();
076            arm.end();
077        } else {
078            menu.findElement(By.linkText(tabLabel)).click();
079        }
080    }
081
082}