001/* 002 * (C) Copyright 2015-2016 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 * Nelson Silva 018 */ 019package org.nuxeo.functionaltests.pages.admincenter.usermanagement; 020 021import java.util.List; 022import java.util.stream.Collectors; 023 024import org.nuxeo.functionaltests.AjaxRequestManager; 025import org.nuxeo.functionaltests.Locator; 026import org.nuxeo.functionaltests.Required; 027import org.nuxeo.functionaltests.forms.Select2WidgetElement; 028import org.openqa.selenium.WebDriver; 029import org.openqa.selenium.WebElement; 030import org.openqa.selenium.support.FindBy; 031 032/** 033 * Edit group details 034 * 035 * @since 7.2 036 */ 037public class GroupEditFormPage extends UsersGroupsBasePage { 038 039 @Required 040 @FindBy(id = "viewGroupView:editGroup:nxl_group:nxw_group_label") 041 WebElement labelInput; 042 043 @Required 044 @FindBy(id = "s2id_viewGroupView:editGroup:nxl_group:nxw_group_members_select2") 045 WebElement membersSelect; 046 047 @Required 048 @FindBy(id = "s2id_viewGroupView:editGroup:nxl_group:nxw_group_subgroups_select2") 049 WebElement subgroupsSelect; 050 051 @Required 052 @FindBy(xpath = "//input[@value=\"Save\"]") 053 WebElement saveButton; 054 055 public GroupEditFormPage(WebDriver driver) { 056 super(driver); 057 } 058 059 public void setLabel(String label) { 060 labelInput.clear(); 061 labelInput.sendKeys(label); 062 } 063 064 /** 065 * @since 8.3 066 */ 067 public List<String> getMembers() { 068 return new Select2WidgetElement(driver, membersSelect, true).getSelectedValues() 069 .stream() 070 .map(WebElement::getText) 071 .collect(Collectors.toList()); 072 } 073 074 public GroupEditFormPage setMembers(String... members) { 075 new Select2WidgetElement(driver, membersSelect, true).selectValues(members); 076 return asPage(GroupEditFormPage.class); 077 } 078 079 /** 080 * @since 8.3 081 */ 082 public GroupEditFormPage addMember(String member) { 083 new Select2WidgetElement(driver, membersSelect, true).selectValue(member); 084 return asPage(GroupEditFormPage.class); 085 } 086 087 /** 088 * @since 8.3 089 */ 090 public List<String> getSubGroups() { 091 return new Select2WidgetElement(driver, subgroupsSelect, true).getSelectedValues() 092 .stream() 093 .map(WebElement::getText) 094 .collect(Collectors.toList()); 095 } 096 097 public GroupEditFormPage setSubGroups(String... subGroups) { 098 new Select2WidgetElement(driver, subgroupsSelect, true).selectValues(subGroups); 099 return asPage(GroupEditFormPage.class); 100 } 101 102 /** 103 * @since 8.3 104 */ 105 public GroupViewTabSubPage save() { 106 AjaxRequestManager arm = new AjaxRequestManager(driver); 107 arm.begin(); 108 Locator.waitUntilEnabledAndClick(saveButton); 109 arm.end(); 110 return asPage(GroupViewTabSubPage.class); 111 } 112 113}