Project

General

Profile

« Previous | Next » 

Revision 50607782

Added by Andreas Kohlbecker almost 13 years ago

refacoring and fine grained testing of taxon profile pages

View differences:

modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonProfilePage.java
11 11
package eu.etaxonomy.dataportal.pages;
12 12

  
13 13
import java.net.MalformedURLException;
14
import java.util.ArrayList;
15
import java.util.List;
16
import java.util.UUID;
14 17

  
15 18
import org.apache.log4j.Logger;
19
import org.junit.Assert;
16 20
import org.openqa.selenium.By;
17 21
import org.openqa.selenium.NoSuchElementException;
18 22
import org.openqa.selenium.RenderedWebElement;
19 23
import org.openqa.selenium.WebDriver;
24
import org.openqa.selenium.WebElement;
20 25
import org.openqa.selenium.support.CacheLookup;
21 26
import org.openqa.selenium.support.FindBy;
22 27

  
28
import eu.etaxonomy.dataportal.DataPortalContext;
29
import eu.etaxonomy.dataportal.elements.DrupalBlock;
30
import eu.etaxonomy.dataportal.elements.FeatureBlock;
23 31
import eu.etaxonomy.dataportal.elements.ImgElement;
32
import eu.etaxonomy.dataportal.elements.LinkElement;
24 33

  
25 34
/**
26 35
 * @author andreas
......
31 40

  
32 41
	public static final Logger logger = Logger.getLogger(TaxonProfilePage.class);
33 42

  
43
	private UUID taxonUuid;
44

  
45
	protected static String drupalPagePathBase = "cdm_dataportal/taxon";
46

  
47
	/* (non-Javadoc)
48
	 * @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
49
	 */
50
	@Override
51
	protected String getDrupalPageBase() {
52
		return drupalPagePathBase;
53
	}
54

  
34 55
	@FindBy(id = "taxonProfileImage")
35 56
	@CacheLookup
36 57
	private RenderedWebElement taxonProfileImage;
37 58

  
38
	public TaxonProfilePage(WebDriver driver) throws MalformedURLException {
39
		super(driver);
59
	@FindBy(id = "featureTOC")
60
	@CacheLookup
61
	private RenderedWebElement tableOfContent;
62

  
63

  
64

  
65
	public TaxonProfilePage(WebDriver driver, DataPortalContext context, UUID taxonUuid) throws MalformedURLException {
66

  
67
		super(driver, context, taxonUuid.toString());
68

  
69
		this.taxonUuid = taxonUuid;
40 70
	}
41 71

  
72

  
42 73
	/**
43 74
	 * Returns the profile image of the taxon profile page. This image is
44 75
	 * located at the top of the page. The Profile Image can be disabled in the
......
60 91
		}
61 92
		return imgElement;
62 93
	}
94

  
95
	public String getTableOfContentHeader() {
96
		if(tableOfContent != null) {
97
			WebElement header = tableOfContent.findElement(By.tagName("h2"));
98
			return header.getText();
99
		}
100
		return null;
101
	}
102

  
103
	public List<LinkElement> getTableOfContentLinks() {
104
		List<LinkElement> linkList = null;
105
		if(tableOfContent != null) {
106
			linkList = new ArrayList<LinkElement>();
107
			List<WebElement> listItems = tableOfContent.findElements(By.tagName("a"));
108
			for (WebElement li : listItems) {
109
				linkList.add( new LinkElement((RenderedWebElement) li) );
110
			}
111
		}
112
		return linkList;
113
	}
114

  
115
	public FeatureBlock getFeatureBlockAt(int position, String featureName, String enclosingTag, String elementTag){
116

  
117
		List<WebElement> featureBlocks = portalContent.findElements(By.className("block-cdm_dataportal-feature"));
118
		Assert.assertTrue("Too few feature block elements", featureBlocks.size() >= position);
119
		for(WebElement b : featureBlocks){
120
			if (b.getAttribute("id").equals("block-cdm_dataportal-feature-" + featureName)){
121
				return new FeatureBlock((RenderedWebElement) b, enclosingTag, elementTag);
122
			}
123
		}
124
		return null;
125
	}
126

  
63 127
}

Also available in: Unified diff