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.Required; 024import org.nuxeo.functionaltests.pages.AbstractPage; 025import org.openqa.selenium.By; 026import org.openqa.selenium.NoSuchElementException; 027import org.openqa.selenium.WebDriver; 028import org.openqa.selenium.WebElement; 029import org.openqa.selenium.support.FindBy; 030 031/** 032 * @since 6.0 033 */ 034public class SearchResultsSubPage extends AbstractPage { 035 036 private static final String SEARCH_RESULTS_XPATH = "//div[contains(@class,'bubbleBox')]"; 037 038 @Required 039 @FindBy(xpath = "//div[@id='nxw_searchContentView']//div[contains(@id, 'nxw_searchContentView_resultsPanel')]/form") 040 protected WebElement resultForm; 041 042 @Required 043 @FindBy(xpath = "//div[@id='nxl_gridSearchLayout:nxw_searchResults_panel']/div/div/h3") 044 public WebElement searchViewTitle; 045 046 public SearchResultsSubPage(WebDriver driver) { 047 super(driver); 048 } 049 050 public int getNumberOfDocumentInCurrentPage() { 051 List<WebElement> result = resultForm.findElements(By.xpath(SEARCH_RESULTS_XPATH)); 052 return result.size(); 053 } 054 055 /** 056 * @return the list of results of the search. 057 */ 058 public List<WebElement> getListResults() { 059 try { 060 return resultForm.findElements(By.xpath(SEARCH_RESULTS_XPATH)); 061 } catch (NoSuchElementException e) { 062 return null; 063 } 064 } 065 066}