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 * <a href="mailto:grenard@nuxeo.com">Guillaume</a> 018 */ 019package org.nuxeo.functionaltests.pages.search; 020 021import java.util.List; 022 023import org.nuxeo.functionaltests.AbstractTest; 024import org.nuxeo.functionaltests.Required; 025import org.nuxeo.functionaltests.contentView.ContentViewElement; 026import org.nuxeo.functionaltests.pages.AbstractPage; 027import org.openqa.selenium.By; 028import org.openqa.selenium.NoSuchElementException; 029import org.openqa.selenium.WebDriver; 030import org.openqa.selenium.WebElement; 031import org.openqa.selenium.support.FindBy; 032 033/** 034 * @since 6.0 035 */ 036public class SearchResultsSubPage extends AbstractPage { 037 038 private static final String SEARCH_RESULTS_XPATH = "//div[contains(@class,'bubbleBox')]"; 039 040 private static final String CONTENT_VIEW_XPATH = "//div[@id='nxw_searchContentView']//div[contains(@id, 'nxw_searchContentView_panel')]"; 041 042 @Required 043 @FindBy(xpath = "//div[@id='nxw_searchContentView']//div[contains(@id, 'nxw_searchContentView_resultsPanel')]/form") 044 protected WebElement resultForm; 045 046 @Required 047 @FindBy(xpath = "//div[@id='nxl_gridSearchLayout:nxw_searchResults_panel']/div/div/h3") 048 public WebElement searchViewTitle; 049 050 public SearchResultsSubPage(WebDriver driver) { 051 super(driver); 052 } 053 054 public int getNumberOfDocumentInCurrentPage() { 055 return getContentView().getItems().size(); 056 } 057 058 /** 059 * @return the list of results of the search. 060 */ 061 public List<WebElement> getListResults() { 062 try { 063 return getContentView().getItems(); 064 } catch (NoSuchElementException e) { 065 return null; 066 } 067 } 068 069 /** 070 * @return the content view of results 071 * @since 8.4 072 */ 073 public ContentViewElement getContentView() { 074 return AbstractTest.getWebFragment(By.xpath(CONTENT_VIEW_XPATH), ContentViewElement.class); 075 } 076 077}