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 * Benoit Delbosc 018 * Nelson Silva 019 */ 020package org.nuxeo.functionaltests.pages.admincenter.usermanagement; 021 022import static org.junit.Assert.assertNotNull; 023 024import org.nuxeo.functionaltests.Required; 025import org.nuxeo.functionaltests.pages.admincenter.AdminCenterBasePage; 026import org.openqa.selenium.WebDriver; 027import org.openqa.selenium.WebElement; 028import org.openqa.selenium.support.FindBy; 029 030/** 031 * Nuxeo User and Groups Base page. (New one in the admin center) 032 * 033 * @since 5.4.2 034 */ 035public class UsersGroupsBasePage extends AdminCenterBasePage { 036 037 @FindBy(xpath = "//div[@id=\"nxw_adminCenterSubTabs_panel\"]/ul/li[@class=\"selected\"]/form/a") 038 public WebElement selectedTab; 039 040 @Required 041 @FindBy(xpath = "//a[@id=\"nxw_UsersManager_form:nxw_UsersManager\"]") 042 public WebElement usersTabLink; 043 044 @Required 045 @FindBy(xpath = "//a[@id=\"nxw_GroupsManager_form:nxw_GroupsManager\"]") 046 public WebElement groupsTabLink; 047 048 protected void clickOnLinkIfNotSelected(WebElement tabLink) { 049 assertNotNull(tabLink); 050 assertNotNull(selectedTab); 051 052 if (!selectedTab.equals(tabLink)) { 053 tabLink.click(); 054 } 055 } 056 057 public UsersGroupsBasePage(WebDriver driver) { 058 super(driver); 059 } 060 061 /** 062 * View the Users tab. 063 */ 064 public UsersTabSubPage getUsersTab(boolean force) { 065 if (force) { 066 usersTabLink.click(); 067 } else { 068 clickOnLinkIfNotSelected(usersTabLink); 069 } 070 return asPage(UsersTabSubPage.class); 071 } 072 073 public UsersTabSubPage getUsersTab() { 074 return getUsersTab(false); 075 } 076 077 /** 078 * View the Groups tab. 079 */ 080 public GroupsTabSubPage getGroupsTab(boolean force) { 081 if (force) { 082 groupsTabLink.click(); 083 } else { 084 clickOnLinkIfNotSelected(groupsTabLink); 085 } 086 return asPage(GroupsTabSubPage.class); 087 } 088 089 public GroupsTabSubPage getGroupsTab() { 090 return getGroupsTab(false); 091 } 092}