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 static org.junit.Assert.assertEquals; 023 024import org.nuxeo.functionaltests.Required; 025import org.openqa.selenium.Alert; 026import org.openqa.selenium.By; 027import org.openqa.selenium.WebDriver; 028import org.openqa.selenium.WebElement; 029import org.openqa.selenium.support.FindBy; 030 031/** 032 * View user details (New one in the admin center) 033 * 034 * @since 5.4.2 035 */ 036public class UserViewTabSubPage extends UsersGroupsBasePage { 037 038 @Required 039 @FindBy(linkText = "View") 040 WebElement viewUserTab; 041 042 @FindBy(linkText = "Delete") 043 WebElement deleteUserLink; 044 045 @FindBy(linkText = "Edit") 046 WebElement editLink; 047 048 @FindBy(linkText = "Change Password") 049 WebElement changePasswordLink; 050 051 @FindBy(xpath = "//div[@id='nxw_userCenterSubTabs_tab_content']//h1") 052 WebElement currentUserName; 053 054 public UserViewTabSubPage(WebDriver driver) { 055 super(driver); 056 } 057 058 public UsersTabSubPage deleteUser() { 059 deleteUserLink.click(); 060 Alert alert = driver.switchTo().alert(); 061 assertEquals("Delete user?", alert.getText()); 062 alert.accept(); 063 return asPage(UsersTabSubPage.class); 064 } 065 066 public UserEditFormPage getEditUserTab() { 067 editLink.click(); 068 return asPage(UserEditFormPage.class); 069 } 070 071 public UserChangePasswordFormPage getChangePasswordUserTab() { 072 changePasswordLink.click(); 073 return asPage(UserChangePasswordFormPage.class); 074 } 075 076 public UsersTabSubPage backToTheList() { 077 findElementWaitUntilEnabledAndClick(By.linkText("Back to the List")); 078 return asPage(UsersTabSubPage.class); 079 } 080 081 /** 082 * @since 6.0 083 */ 084 public void checkUserName(String expectedName) { 085 assertEquals(expectedName, getCurrentUserName().getText()); 086 } 087 088 /** 089 * @since 6.0 090 */ 091 public WebElement getCurrentUserName() { 092 return currentUserName; 093 } 094}