Project

General

Profile

Download (3.08 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2011 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.dataportal.pages;
11

    
12
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.concurrent.TimeUnit;
15

    
16
import org.apache.log4j.Logger;
17
import org.openqa.selenium.By;
18
import org.openqa.selenium.WebDriver;
19
import org.openqa.selenium.WebElement;
20
import org.openqa.selenium.support.CacheLookup;
21
import org.openqa.selenium.support.FindBy;
22

    
23
import eu.etaxonomy.dataportal.DataPortalContext;
24
import eu.etaxonomy.dataportal.elements.TaxonListElement;
25
import eu.etaxonomy.dataportal.selenium.AllTrue;
26
import eu.etaxonomy.dataportal.selenium.PageTitleValidated;
27
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
28

    
29
/**
30
 * @author andreas
31
 * @date Aug 12, 2011
32
 *
33
 */
34
public class TaxonSearchResultPage extends GenericPortalPage {
35

    
36
	public static final Logger logger = Logger.getLogger(TaxonSearchResultPage.class);
37

    
38
	private static String drupalPagePathBase = "cdm_dataportal/search/taxon";
39

    
40
	@FindBy(id="search_results")
41
	@CacheLookup
42
	private WebElement searchResults;
43

    
44
	//class=page_options
45
	@FindBy(className="page_options")
46
	@CacheLookup
47
	private WebElement pageOptions;
48

    
49
	//class=pager
50
	@FindBy(className="pager")
51
	@CacheLookup
52
	private WebElement pager;
53

    
54

    
55
	/* (non-Javadoc)
56
	 * @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
57
	 */
58
	@Override
59
	protected String getDrupalPageBase() {
60
		return drupalPagePathBase;
61
	}
62

    
63
	/**
64
	 * @param driver
65
	 * @param context
66
	 * @throws Exception
67
	 */
68
	public TaxonSearchResultPage(WebDriver driver, DataPortalContext context) throws Exception {
69
		super(driver, context);
70
	}
71

    
72

    
73
	/**
74
	 * Find and return the result n-th item of the result list.
75
	 * The item can be specified by the index paramter.
76
	 * @param index 1-based index to identify the resultset item.
77
	 * This index will be used in a xpath query.
78
	 * @return
79
	 */
80
	public TaxonListElement getResultItem(int index) {
81

    
82
		TaxonListElement entry = new TaxonListElement(searchResults.findElement(By.xpath("ul/li[" + index + "]")));
83

    
84
		return entry;
85
	}
86

    
87
	/**
88
	 * Find and returns all items of the result list.
89
	 * @return
90
	 */
91
	public List<TaxonListElement> getResultItems() {
92

    
93
		List<WebElement> entryList = searchResults.findElements(By.xpath("/ul/li"));
94
		List<TaxonListElement> taxonListElements = new ArrayList<TaxonListElement>();
95
		for(WebElement entry : entryList){
96
			taxonListElements.add(new TaxonListElement(entry));
97
		}
98
		return taxonListElements;
99
	}
100

    
101
	/**
102
	 * @throws Exception
103
	 *
104
	 */
105
	public <T extends PortalPage> T  clickTaxonName(TaxonListElement taxonListElement) throws Exception {
106

    
107
		WebElement taxonlink = taxonListElement.getElement().findElement(By.tagName("a"));
108
		logger.info("clicking on link to " + taxonlink.getAttribute("href"));
109
		taxonlink.click();
110
		wait.withTimeout(2, TimeUnit.MINUTES).until(new VisibilityOfElementLocated(By.id("featureTOC")));
111
		return (T) new TaxonProfilePage(driver, context);
112

    
113
	}
114

    
115

    
116

    
117
}
(5-5/6)