001/* 002 * (C) Copyright 2017 Nuxeo (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 * Kevin Leturc 018 */ 019package org.nuxeo.functionaltests.contentView; 020 021import org.nuxeo.functionaltests.AbstractTest; 022import org.nuxeo.functionaltests.AjaxRequestManager; 023import org.nuxeo.functionaltests.fragment.WebFragmentImpl; 024import org.nuxeo.functionaltests.pages.DocumentBasePage; 025import org.nuxeo.functionaltests.pages.tabs.AbstractContentTabSubPage; 026import org.nuxeo.functionaltests.pages.tabs.ContentTabSubPage; 027import org.openqa.selenium.By; 028import org.openqa.selenium.WebDriver; 029import org.openqa.selenium.WebElement; 030import org.openqa.selenium.support.FindBy; 031import org.openqa.selenium.support.ui.Select; 032 033/** 034 * @since 9.1 035 */ 036public class ContentViewUpperActions extends WebFragmentImpl { 037 038 @FindBy(id = "nxw_contentViewActions_selectContentViewPageSize:contentViewPageSizeSelector") 039 WebElement selectContentPageSize; 040 041 @FindBy(id = "nxw_contentViewActions_refreshContentView_form:nxw_contentViewActions_refreshContentView") 042 WebElement refreshContentLink; 043 044 public ContentViewUpperActions(WebDriver driver, WebElement element) { 045 super(driver, element); 046 } 047 048 public ContentTabSubPage selectPageSize(int size) { 049 return selectPageSize(size, ContentTabSubPage.class); 050 } 051 052 public <T extends AbstractContentTabSubPage> T selectPageSize(int size, Class<T> pageClassToProxy) { 053 AjaxRequestManager arm = new AjaxRequestManager(driver); 054 arm.begin(); 055 Select select = new Select(selectContentPageSize); 056 select.selectByVisibleText(String.valueOf(size)); 057 arm.end(); 058 return AbstractTest.asPage(pageClassToProxy); 059 } 060 061 public DocumentBasePage refreshContent() { 062 return refreshContent(DocumentBasePage.class); 063 } 064 065 public <T extends DocumentBasePage> T refreshContent(Class<T> pageClassToProxy) { 066 AjaxRequestManager arm = new AjaxRequestManager(driver); 067 arm.begin(); 068 refreshContentLink.click(); 069 arm.end(); 070 return AbstractTest.asPage(pageClassToProxy); 071 } 072 073 public void clickOnActionByTitle(String title) { 074 AjaxRequestManager arm = new AjaxRequestManager(driver); 075 arm.begin(); 076 getActionByTitle(title).click(); 077 arm.end(); 078 } 079 080 public WebElement getActionByTitle(String title) { 081 return getElement().findElement(By.xpath("//img[@alt=\"" + title + "\"]")); 082 } 083 084}