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 * Antoine Taillefer 019 */ 020package org.nuxeo.functionaltests.pages.admincenter.usermanagement; 021 022import org.nuxeo.functionaltests.AbstractTest; 023import org.nuxeo.functionaltests.AjaxRequestManager; 024import org.nuxeo.functionaltests.Required; 025import org.openqa.selenium.By; 026import org.openqa.selenium.NoSuchElementException; 027import org.openqa.selenium.WebDriver; 028import org.openqa.selenium.WebElement; 029import org.openqa.selenium.support.FindBy; 030 031/** 032 * Users Tab Page of the users & groups management (New one in the admin center) 033 * 034 * @since 5.4.2 035 */ 036public class UsersTabSubPage extends UsersGroupsBasePage { 037 038 @Required 039 @FindBy(id = "usersListingView:createUserActionsForm:createUserButton") 040 WebElement createNewUserLink; 041 042 @FindBy(id = "usersListingView:searchForm:searchText") 043 WebElement searchInput; 044 045 @FindBy(id = "usersListingView:searchForm:searchButton") 046 WebElement searchButton; 047 048 public UsersTabSubPage(WebDriver driver) { 049 super(driver); 050 } 051 052 public UserCreationFormPage getUserCreatePage() { 053 createNewUserLink.click(); 054 return asPage(UserCreationFormPage.class); 055 } 056 057 public UsersTabSubPage searchUser(String query) { 058 searchInput.clear(); 059 searchInput.sendKeys(query); 060 AjaxRequestManager arm = new AjaxRequestManager(driver); 061 arm.begin(); 062 searchButton.click(); 063 arm.end(); 064 return asPage(UsersTabSubPage.class); 065 } 066 067 /** 068 * Is the username was found in the last search result page. 069 */ 070 public boolean isUserFound(String username) { 071 try { 072 findElementWithTimeout(By.linkText(username), AbstractTest.LOAD_SHORT_TIMEOUT_SECONDS * 1000); 073 } catch (NoSuchElementException e) { 074 return false; 075 } 076 return true; 077 } 078 079 public UserViewTabSubPage viewUser(String username) { 080 findElementWithTimeout(By.linkText(username)).click(); 081 return asPage(UserViewTabSubPage.class); 082 } 083 084}