001/* 002 * (C) Copyright 2014 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.contentView; 020 021import org.nuxeo.functionaltests.AjaxRequestManager; 022import org.nuxeo.functionaltests.Required; 023import org.nuxeo.functionaltests.fragment.WebFragmentImpl; 024import org.openqa.selenium.By; 025import org.openqa.selenium.WebDriver; 026import org.openqa.selenium.WebElement; 027import org.openqa.selenium.support.FindBy; 028 029/** 030 * Represents a content view element. 031 * 032 * @since 7.1 033 */ 034public class ContentViewElement extends WebFragmentImpl { 035 036 public static enum ResultLayout { 037 THUMBNAIL("Thumbnail view"), LISTING("List view"); 038 039 private final String title; 040 041 ResultLayout(String title) { 042 this.title = title; 043 } 044 } 045 046 @FindBy(className = "contentViewUpperActions") 047 @Required 048 private WebElement upperActions; 049 050 public ContentViewElement(WebDriver driver, WebElement element) { 051 super(driver, element); 052 } 053 054 public WebElement getActionByTitle(String title) { 055 return upperActions.findElement(By.xpath("//img[@alt=\"" + title + "\"]")); 056 } 057 058 public void switchToResultLayout(ResultLayout layout) { 059 AjaxRequestManager a = new AjaxRequestManager(driver); 060 a.watchAjaxRequests(); 061 getActionByTitle(layout.title).click(); 062 a.waitForAjaxRequests(); 063 } 064}