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:

.gitattributes
258 258
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/SystemUtils.java -text
259 259
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java -text
260 260
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/BaseElement.java -text
261
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/DescriptionElementRepresentation.java -text
262
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/DrupalBlock.java -text
263
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java -text
261 264
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/ImgElement.java -text
262 265
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/LinkElement.java -text
263 266
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalSeleniumRCTestBase.java -text
......
272 275
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu/etaxonomy/dataportal/DataPortalTest.xml -text
273 276
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/log4j.properties -text
274 277
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java -text
275
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CichorieaeSearchTest.java -text
276
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java -text
277
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusTaxonProfileTest.java -text
278
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java -text
278
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/CichorieaeSearchTest.java -text
279
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Allium_guttatum_subsp_guttatum_TaxonProfileTest.java -text
280
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/CyprusSearchTest.java -text
281
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/flMalesiana/FloraMalesianaPolytomousKeyTest.java -text
279 282
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi -text
280 283
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firebug-1.6.2.xpi -text
281 284
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/resources/org/mozilla/addons/firexpath-0.9.6.1-fx.xpi -text
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/BaseElement.java
21 21
 */
22 22
public class BaseElement {
23 23

  
24
	public List<String> classAttributes = null;
24

  
25
	private RenderedWebElement element;
26

  
27
	private List<String> classAttributes = null;
25 28

  
26 29
	private String text = null;
27 30

  
31

  
32
	public RenderedWebElement getElement() {
33
		return element;
34
	}
35

  
28 36
	public String getText() {
29 37
		return text;
30 38
	}
......
46 54
	 */
47 55
	public BaseElement(RenderedWebElement element) {
48 56

  
57
		this.element = element;
58

  
49 59
		// read text
50 60
		text = element.getText();
51 61

  
......
56 66
		}
57 67
	}
58 68

  
69

  
59 70
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/DescriptionElementRepresentation.java
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.elements;
11

  
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import org.openqa.selenium.By;
16
import org.openqa.selenium.RenderedWebElement;
17
import org.openqa.selenium.WebElement;
18

  
19
public class DescriptionElementRepresentation extends BaseElement{
20

  
21
	List sources = new ArrayList(); // may be LinkElement or BaseElement
22

  
23
	public List getSources() {
24
		return sources;
25
	}
26

  
27
	/**
28
	 * @param element
29
	 */
30
	public DescriptionElementRepresentation(RenderedWebElement element) {
31
		super(element);
32

  
33
		for (WebElement source : element.findElements(By.className("sources"))) {
34
			if(source.getTagName().equals("a")){
35
				sources.add(new LinkElement((RenderedWebElement) source));
36
			} else {
37
				sources.add(new BaseElement((RenderedWebElement) source));
38
			}
39
		}
40
	}
41

  
42
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/DrupalBlock.java
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.elements;
11

  
12
import org.openqa.selenium.By;
13
import org.openqa.selenium.NoSuchElementException;
14
import org.openqa.selenium.RenderedWebElement;
15
import org.openqa.selenium.WebElement;
16

  
17

  
18
/**
19
 * @author andreas
20
 * @date Jul 4, 2011
21
 *
22
 */
23
public class DrupalBlock extends BaseElement {
24

  
25
	private String header;
26

  
27
	protected RenderedWebElement content;
28

  
29
	/**
30
	 * @param element
31
	 */
32
	public DrupalBlock(RenderedWebElement element) {
33

  
34
		super(element);
35

  
36
		content = (RenderedWebElement) element.findElement(By.className("content"));
37

  
38
		try {
39
			WebElement headerElement = element.findElement(By.tagName("h2"));
40
			header = headerElement.getText();
41
		} catch (NoSuchElementException e){
42
			// IGNORE //
43
		}
44
	}
45

  
46
	public String getHeader() {
47
		return header;
48
	}
49

  
50
	public RenderedWebElement getContent() {
51
		return content;
52
	}
53

  
54
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java
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.elements;
11

  
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import static junit.framework.Assert.*;
16

  
17
import org.openqa.selenium.By;
18
import org.openqa.selenium.RenderedWebElement;
19
import org.openqa.selenium.WebElement;
20

  
21
/**
22
 * @author andreas
23
 * @date Jul 4, 2011
24
 *
25
 */
26
public class FeatureBlock extends DrupalBlock {
27

  
28
	private List<String> footNoteKeys = new ArrayList<String>();
29

  
30
	private List<String> footNotes = new ArrayList<String>();
31

  
32
	private List<DescriptionElementRepresentation> descriptionElements = new ArrayList<DescriptionElementRepresentation>();
33

  
34
	private String featureType = null;
35

  
36

  
37
	public List<String> getFootNoteKeys() {
38
		return footNoteKeys;
39
	}
40

  
41
	public List<String> getFootNotes() {
42
		return footNotes;
43
	}
44

  
45
	public List<DescriptionElementRepresentation> getDescriptionElements() {
46
		return descriptionElements;
47
	}
48

  
49
	public String getFeatureType() {
50
		return featureType;
51
	}
52

  
53

  
54
	/**
55
	 * @param element
56
	 */
57
	public FeatureBlock(RenderedWebElement element, String enclosingTag, String elementTag) {
58
		super(element);
59

  
60
		List<WebElement> fnkList = element.findElements(By.className("footnote-key"));
61
		for(WebElement fnk : fnkList) {
62
			footNoteKeys.add(fnk.getText());
63
		}
64

  
65
		List<WebElement> fnList = element.findElements(By.className("footnote"));
66
		for(WebElement fn : fnList) {
67
			footNotes.add(fn.getText());
68
		}
69

  
70
		RenderedWebElement descriptionElementsRepresentation = (RenderedWebElement) element.findElement(By.className("description"));
71
		featureType = descriptionElementsRepresentation.getAttribute("id");
72
		assertEquals("Unexpected tag enclosing description element representations", enclosingTag, descriptionElementsRepresentation.getTagName());
73

  
74
		for(WebElement el : descriptionElementsRepresentation.findElements(By.tagName(elementTag))){
75
			descriptionElements.add(new DescriptionElementRepresentation((RenderedWebElement)el));
76
		}
77

  
78
	}
79

  
80

  
81

  
82
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/LinkElement.java
10 10

  
11 11
package eu.etaxonomy.dataportal.elements;
12 12

  
13
import java.net.MalformedURLException;
14
import java.net.URL;
15
import java.util.Arrays;
16
import java.util.List;
17

  
18 13
import org.openqa.selenium.RenderedWebElement;
19 14

  
20 15
/**
......
24 19
 */
25 20
public class LinkElement extends BaseElement {
26 21

  
27
	private URL url = null;
28
	public URL getUrl() {
29
		return url;
22
	private String href = null;
23
	public String getUrl() {
24
		return href;
30 25
	}
31 26

  
32
	public void setUrl(URL url) {
33
		this.url = url;
27
	public void setHref(String href) {
28
		this.href = href;
34 29
	}
35 30

  
36 31

  
......
40 35

  
41 36
		// read src url
42 37
		if (a.getAttribute("href") != null) {
43
			try {
44
				setUrl(new URL(a.getAttribute("href")));
45
			} catch (MalformedURLException e) {
46
				// IGNORE //
47
			}
38
				setHref(a.getAttribute("href"));
48 39
		}
49 40

  
50 41
	}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/CdmDataPortalTestBase.java
3 3
 */
4 4
package eu.etaxonomy.dataportal.junit;
5 5

  
6
import java.io.IOException;
7

  
8 6
import org.apache.log4j.Logger;
9 7
import org.junit.AfterClass;
10 8
import org.junit.BeforeClass;
11 9
import org.junit.runner.RunWith;
12 10
import org.openqa.selenium.WebDriver;
13
import org.openqa.selenium.chrome.ChromeDriver;
14
import org.openqa.selenium.firefox.FirefoxDriver;
15
import org.openqa.selenium.firefox.FirefoxProfile;
16
import org.openqa.selenium.ie.InternetExplorerDriver;
17 11

  
18
import eu.etaxonomy.dataportal.Browser;
19 12
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.SystemUtils;
21 13
import eu.etaxonomy.dataportal.selenium.WebDriverFactory;
22 14

  
23 15
/**
......
44 36

  
45 37
	@BeforeClass
46 38
	public static void setUpDriver() {
39
		logger.debug("@BeforeClass: setUpDriver()");
47 40
		driver = WebDriverFactory.newWebDriver();
48 41
	}
49 42

  
50 43
	@AfterClass
51 44
	public static void closeDriver() {
45
		logger.debug("@AfterClass: closeDriver()");
52 46
		if (driver != null) {
53 47
			driver.quit();
54 48
		}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/junit/DataPortalContextSuite.java
48 48
	private final List<Runner> runners = new ArrayList<Runner>();
49 49

  
50 50

  
51
	private class TestClassRunnerWithDataPortalContext extends
52
	BlockJUnit4ClassRunner {
51
	private class TestClassRunnerWithDataPortalContext extends BlockJUnit4ClassRunner {
53 52

  
54 53
		private final DataPortalContext context;
55 54

  
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/PolytomousKeyPage.java
2 2

  
3 3
import java.net.MalformedURLException;
4 4
import java.util.List;
5
import java.util.UUID;
5 6

  
6 7
import org.apache.log4j.Logger;
7 8
import org.junit.Assert;
......
13 14
import org.openqa.selenium.support.FindBy;
14 15
import org.openqa.selenium.support.PageFactory;
15 16

  
17
import eu.etaxonomy.dataportal.DataPortalContext;
16 18
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
17 19

  
18
public class PolytomousKeyPage extends PortalPage{
19

  
20
	public PolytomousKeyPage(WebDriver driver) throws MalformedURLException {
21
		super(driver);
22
	}
20
public class PolytomousKeyPage extends PortalPage {
23 21

  
24 22
	public static final Logger logger = Logger.getLogger(PolytomousKeyPage.class);
25 23

  
24
	private static String drupalPagePathBase = "cdm_dataportal/polytomousKey";
25

  
26
	/* (non-Javadoc)
27
	 * @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
28
	 */
29
	@Override
30
	protected String getDrupalPageBase() {
31
		return drupalPagePathBase;
32
	}
33

  
26 34
	@FindBy(className="polytomousKey")
27
  	@CacheLookup
35
	@CacheLookup
28 36
	private WebElement keyTable;
29 37

  
30 38
	private List<WebElement> keyTableRows;
31 39

  
32

  
40
	public PolytomousKeyPage(WebDriver driver, DataPortalContext context, UUID keyUuid) throws MalformedURLException {
41
		super(driver, context, keyUuid.toString());
42
	}
33 43

  
34 44
	public static class KeyLineData{
35 45

  
......
84 94
		return PageFactory.initElements(driver, PortalPage.class);
85 95
	}
86 96

  
97

  
98

  
99

  
100

  
87 101
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java
6 6
import java.util.List;
7 7

  
8 8
import org.apache.log4j.Logger;
9
import org.junit.Assert;
9 10
import org.openqa.selenium.By;
11
import org.openqa.selenium.NoSuchElementException;
10 12
import org.openqa.selenium.RenderedWebElement;
11 13
import org.openqa.selenium.WebDriver;
12 14
import org.openqa.selenium.WebElement;
......
14 16
import org.openqa.selenium.support.FindBy;
15 17
import org.openqa.selenium.support.FindBys;
16 18
import org.openqa.selenium.support.PageFactory;
19
import org.openqa.selenium.support.ui.LoadableComponent;
17 20

  
21
import eu.etaxonomy.dataportal.DataPortalContext;
18 22
import eu.etaxonomy.dataportal.TestConfiguration;
19 23
import eu.etaxonomy.dataportal.elements.LinkElement;
20 24
import eu.etaxonomy.dataportal.selenium.JUnitWebDriverWait;
21 25

  
22
public class PortalPage {
26
public abstract class  PortalPage {
23 27

  
24 28
	public static final Logger logger = Logger.getLogger(PortalPage.class);
25 29

  
30
	protected final static String DRUPAL_PAGE_QUERY_BASE = "?q=";
31

  
26 32
	protected WebDriver driver;
33

  
27 34
	protected final JUnitWebDriverWait wait;
28
	protected URL initialUrl;
35

  
36

  
37
	/**
38
	 * Implementations of this method will supply the raltive
39
	 * path to the Drupal page. This path will usally have the form
40
	 * <code>cdm_dataportal/{nodetype}</code>. For example the taxon pages all
41
	 * have the page base <code>cdm_dataportal/taxon</code>
42
	 * @return
43
	 */
44
	protected abstract String getDrupalPageBase();
45

  
46
	private String drupalPagePath;
47

  
48
	protected URL pageUrl;
49

  
50
	// ==== WebElements === //
29 51

  
30 52
	@FindBy(id="cdm_dataportal.node")
31
	@CacheLookup
32
	private RenderedWebElement portalContent;
53
	protected RenderedWebElement portalContent;
33 54

  
34 55
	@FindBy(tagName="title")
35 56
	@CacheLookup
36
	private RenderedWebElement title;
57
	protected RenderedWebElement title;
58

  
59
	@FindBy(className="node")
60
	protected RenderedWebElement node;
61

  
37 62

  
38
	//tabs primary
39 63
	@FindBys({@FindBy(id="tabs-wrapper"), @FindBy(className="primary")})
40 64
	@CacheLookup
41
	private RenderedWebElement primaryTabs;
65
	protected RenderedWebElement primaryTabs;
66

  
67

  
68
	public PortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException {
42 69

  
43
	public PortalPage(WebDriver driver) throws MalformedURLException {
44 70
		this.driver = driver;
45
		this.initialUrl = new URL(driver.getCurrentUrl());
71

  
46 72
		this.wait = new JUnitWebDriverWait(driver, 25);
47 73

  
48
		logger.info("loading " + initialUrl);
74
		this.drupalPagePath = getDrupalPageBase() + "/" + pagePathSuffix;
75

  
76
		this.pageUrl = new URL(context.getBaseUri().toString() + DRUPAL_PAGE_QUERY_BASE + drupalPagePath);
77

  
78
		// tell browser to navigate to the page
79
		driver.get(pageUrl.toString());
80

  
81
	    // This call sets the WebElement fields.
82
	    PageFactory.initElements(driver, this);
83

  
84

  
85
		logger.info("loading " + pageUrl);
49 86
	}
50 87

  
51
	public void goToInitialPage() {
52
		driver.get(initialUrl.toString());
53
		PageFactory.initElements(driver, this);
88
	public void get() {
89
		if(!driver.getCurrentUrl().equals(pageUrl.toString())){
90
			driver.get(pageUrl.toString());
91
			PageFactory.initElements(driver, this);
92
		}
93
	}
94

  
95
	public String getDrupalPagePath() {
96
		return drupalPagePath;
54 97
	}
55 98

  
56 99
	/**
......
61 104
		return title.getText();
62 105
	}
63 106

  
107
	public String getAuthorInformationText() {
108

  
109
		RenderedWebElement authorInformation = null;
110

  
111
		try {
112
			authorInformation  = (RenderedWebElement)node.findElement(By.className("submitted"));
113
		} catch (NoSuchElementException e) {
114
			// IGNORE //
115
		}
116

  
117

  
118
		if(authorInformation != null){
119
			return authorInformation.getText();
120
		} else {
121
			return null;
122
		}
123
	}
124

  
64 125
	public List<LinkElement> getPrimaryTabs(){
65 126
		List<LinkElement> tabs = new ArrayList<LinkElement>();
66 127
		List<WebElement> links = primaryTabs.findElements(By.tagName("a"));
......
83 144
		return driver.getCurrentUrl();
84 145
	}
85 146

  
147

  
86 148
	/**
87 149
	 * return the <code>scheme://domain:port</code> part of the initial url of this page.
88 150
	 * @return
89 151
	 */
90 152
	public String getInitialUrlBase() {
91
		return initialUrl.getProtocol() + "://" + initialUrl.getHost() + initialUrl.getPort();
153
		return pageUrl.getProtocol() + "://" + pageUrl.getHost() + pageUrl.getPort();
92 154
	}
93 155

  
94 156
	public boolean equals(Object obj) {
......
101 163
		}
102 164
	}
103 165

  
166

  
104 167
}
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
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/log4j.properties
1 1
#
2 2
#
3
# If you are having problems with logging you may debug Log4J initialization, 
4
# start the application with a system property log4j.configDebug set to "true". 
3
# If you are having problems with logging you may debug Log4J initialization,
4
# start the application with a system property log4j.configDebug set to "true".
5 5
# E.g.:
6 6
#
7 7
#     java -Dlog4j.configDebug=true
......
13 13
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
14 14
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
15 15
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
16

  
17
#log4j.logger.eu.etaxonomy.dataportal=DEBUG
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java
24 24
@DataPortalContexts( { DataPortalContext.cichorieae })
25 25
public class ExampleTest extends CdmDataPortalSeleniumRCTestBase {
26 26

  
27
	@Test
27
	//@Test
28 28
	public void testSearchLCommunis() throws Exception {
29 29
		driver.get(getBaseUrl()
30 30
						+ "?query=Lapsana+com*&search[tree]=534e190f-3339-49ba-95d9-fa27d5493e3e&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
......
54 54
	 *
55 55
	 * @throws Exception
56 56
	 */
57
	@Test
57
	//@Test
58 58
	public void testSearchLCommunisUsingSeleniumRC() throws Exception {
59 59
		selenium.open("?query=Lapsana+com*&search[tree]=534e190f-3339-49ba-95d9-fa27d5493e3e&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
60 60
		selenium.isTextPresent("Lapsana");
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CichorieaeSearchTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests;
11

  
12
import junit.framework.Assert;
13

  
14
import org.junit.Test;
15
import org.openqa.selenium.By;
16
import org.openqa.selenium.RenderedWebElement;
17
import org.openqa.selenium.WebElement;
18

  
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
22

  
23
@DataPortalContexts( { DataPortalContext.cichorieae })
24
public class CichorieaeSearchTest extends CdmDataPortalTestBase {
25

  
26
	@Test
27
	public void testSearchLCommunis() throws Exception {
28
		driver.get(getBaseUrl()
29
						+ "?query=Lapsana+com*&search[tree]=534e190f-3339-49ba-95d9-fa27d5493e3e&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
30
		WebElement taxonElement = driver.findElement(By
31
				.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[@ref='/name/f280f79f-5903-47b0-8352-53e4204c6cf1']"));
32

  
33
		WebElement nameElement = taxonElement.findElement(By.className("BotanicalName"));
34

  
35
		RenderedWebElement namePart1 = (RenderedWebElement) nameElement.findElement(By.xpath("span[1]"));
36
		Assert.assertEquals("Lapsana", namePart1.getText());
37
		Assert.assertEquals("italic", namePart1.getValueOfCssProperty("font-style"));
38

  
39
		RenderedWebElement namePart2 = (RenderedWebElement) nameElement.findElement(By.xpath("span[2]"));
40
		Assert.assertEquals("communis", namePart2.getText());
41
		Assert.assertEquals("italic", namePart2.getValueOfCssProperty("font-style"));
42

  
43
		RenderedWebElement authorPart = (RenderedWebElement) nameElement.findElement(By.xpath("span[3]"));
44
		Assert.assertEquals("L.", authorPart.getText());
45
		Assert.assertEquals("normal", authorPart.getValueOfCssProperty("font-style"));
46

  
47
		RenderedWebElement referenceElement = (RenderedWebElement) taxonElement.findElement(By.className("reference"));
48
		Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
49
	}
50

  
51
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusSearchTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests;
11

  
12
import org.junit.Assert;
13
import org.junit.Ignore;
14
import org.junit.Test;
15
import org.openqa.selenium.By;
16
import org.openqa.selenium.RenderedWebElement;
17
import org.openqa.selenium.WebElement;
18

  
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
22

  
23
/**
24
 * @author a.kohlbecker
25
 *
26
 */
27

  
28
@DataPortalContexts( { DataPortalContext.cyprus })
29
public class CyprusSearchTest extends CdmDataPortalTestBase{
30

  
31
	/**
32
	 * see http://dev.e-taxonomy.eu/trac/ticket/2350
33
	 */
34
	@Test
35
	@Ignore
36
	public void searchResultsWithoutAnnotationFootnotes(){
37
		driver.get(getBaseUrl() + "?query=Genis*&search[tree]=0c2b5d25-7b15-4401-8b51-dd4be0ee5cab&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
38

  
39
		// --- This variant is slower in FF that using the full xpath
40
		//		WebElement container = driver.findElement(By.id("squeeze"));
41
		//		RenderedWebElement element = (RenderedWebElement)container.findElement(By.xpath("div/div/ul/li/span[contains(@class, 'footnote-key')]"));
42

  
43
		// --- using the full xpath
44
		RenderedWebElement element = (RenderedWebElement)driver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[contains(@class, 'footnote-key')]"));
45
		Assert.assertNull("result set entries must not have footnote keys", element);
46
	}
47

  
48
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/CyprusTaxonProfileTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests;
11

  
12
import java.util.List;
13

  
14
import org.junit.Assert;
15
import org.junit.Test;
16
import org.openqa.selenium.support.PageFactory;
17

  
18
import eu.etaxonomy.dataportal.DataPortalContext;
19
import eu.etaxonomy.dataportal.elements.ImgElement;
20
import eu.etaxonomy.dataportal.elements.LinkElement;
21
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
22
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
23
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
24

  
25
/**
26
 * @author a.kohlbecker
27
 *
28
 */
29

  
30
@DataPortalContexts( { DataPortalContext.cyprus })
31
public class CyprusTaxonProfileTest extends CdmDataPortalTestBase{
32

  
33
	@Test
34
	public void allium_guttatum_subsp_guttatum(){
35

  
36
		String pageUrlString = getBaseUrl() + "?q=cdm_dataportal/taxon/6d04598b-3852-4038-91c9-13c7581b21a6";
37
		driver.get(pageUrlString);
38
		TaxonProfilePage p = PageFactory.initElements(driver, TaxonProfilePage.class);
39

  
40
		Assert.assertEquals(prepareTitle("Allium guttatum subsp. guttatum"), p.getTitle());
41

  
42
		List<LinkElement> primaryTabs = p.getPrimaryTabs();
43
		Assert.assertEquals("Expecting 3 tabs", 3, primaryTabs.size());
44
		Assert.assertEquals("General", primaryTabs.get(0).getText());
45
		Assert.assertEquals("Synonymy", primaryTabs.get(1).getText());
46
		Assert.assertEquals("Images", primaryTabs.get(2).getText());
47

  
48
		ImgElement profileImage = p.getProfileImage();
49
		Assert.assertNotNull("Expecting profile images to be switched on", profileImage);
50
		Assert.assertEquals("http://media.bgbm.org/erez/erez?src=EditWP6/zypern/photos/Allium_guttatum_guttatum_A1.jpg", profileImage.getUrl().toString());
51
		Assert.assertEquals(400, profileImage.getDimension().getHeight(), 0.5);
52
		Assert.assertEquals(250, profileImage.getDimension().getWidth(), 0.5);
53

  
54

  
55
	}
56

  
57
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/FloraMalesianaPolytomousKeyTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests;
11

  
12
import org.junit.Assert;
13
import org.junit.Test;
14
import org.openqa.selenium.support.PageFactory;
15

  
16
import eu.etaxonomy.dataportal.DataPortalContext;
17
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
18
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
19
import eu.etaxonomy.dataportal.pages.PolytomousKeyPage;
20
import eu.etaxonomy.dataportal.pages.PolytomousKeyPage.KeyLineData;
21
import eu.etaxonomy.dataportal.pages.PolytomousKeyPage.LinkClass;
22
import eu.etaxonomy.dataportal.pages.PortalPage;
23

  
24
/**
25
 * @author a.kohlbecker
26
 *
27
 */
28

  
29
@DataPortalContexts({ DataPortalContext.floramalesiana })
30
public class FloraMalesianaPolytomousKeyTest extends CdmDataPortalTestBase {
31

  
32
	/**
33
	 * see http://dev.e-taxonomy.eu/trac/ticket/2350
34
	 *
35
	 */
36
	@Test
37
	public void key_to_Malaysian_Sapindaceae_Genera() {
38

  
39
		String pageUrlString = getBaseUrl() + "?q=cdm_dataportal/polytomousKey/40cf3253-ce7a-4ad6-9a32-27695c36eb5d";
40

  
41
		driver.get(pageUrlString);
42

  
43
		PolytomousKeyPage p = PageFactory.initElements(driver, PolytomousKeyPage.class);
44
		PortalPage targetPage;
45
		KeyLineData keyLineData;
46

  
47

  
48
		Assert.assertEquals(prepareTitle("KEY I TO THE MALESIAN GENERA (based on vegetative and flower characters) (F. Adema)"), p.getTitle());
49

  
50
		// -------- //
51
		keyLineData = new KeyLineData("0",
52
				"Trees or shrubs, exceptionally lianas. Leaves simple, unifoliolate, (bi)pinnate or digitate. Inflorescences without basal tendrils",
53
				LinkClass.nodeLinkToNode, "1");
54
		targetPage = p.followPolytomousKeyLine(0, keyLineData);
55
		Assert.assertEquals(p, targetPage);
56

  
57
		// -------- //
58
		keyLineData = new KeyLineData("0'", "Herbaceous or woody climbers. Leaves biternate. Inflorescences with basal tendrils",
59
				LinkClass.nodeLinkToTaxon, "Cardiospermum");
60
		targetPage = p.followPolytomousKeyLine(1, keyLineData);
61
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
62
		p.goToInitialPage();
63

  
64
		// -------- //
65
		keyLineData = new KeyLineData("1", "Leaves simple, unifoliolate, (im)paripinnate or digitate", LinkClass.nodeLinkToNode, "2");
66
		targetPage = p.followPolytomousKeyLine(2, keyLineData);
67
		Assert.assertEquals(p, targetPage);
68

  
69
		// -------- //
70
		keyLineData = new KeyLineData("1'", "Leaves bipinnate", LinkClass.nodeLinkToTaxon, "Tristiropsis");
71
		targetPage = p.followPolytomousKeyLine(3, keyLineData);
72
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
73
		p.goToInitialPage();
74

  
75
		// -------- //
76
		keyLineData = new KeyLineData(
77
				"116",
78
				"Leaflets entire or crenulate, lower surface without small glands. Inflorescences axillary, sometimes together pseudoterminal; cymes dense, many-flowered",
79
				LinkClass.nodeLinkToTaxon, "Synima cordierorum");
80
		targetPage = p.followPolytomousKeyLine(126, keyLineData);
81
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
82
		p.goToInitialPage();
83

  
84
		// -------- //
85
		keyLineData = new KeyLineData(
86
				"116'",
87
				"Leaflets entire, lower surface usually with small glands. Inflorescences axillary, together mostly pseudoterminal, by the shifting aside and suppression of the terminal bud sometimes seemingly truly terminal; cymes lax, 1- or few-flowered",
88
				LinkClass.nodeLinkToTaxon, "Trigonachras");
89
		targetPage = p.followPolytomousKeyLine(127, keyLineData);
90
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
91

  
92
	}
93

  
94
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/CichorieaeSearchTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests.cichorieae;
11

  
12
import junit.framework.Assert;
13

  
14
import org.junit.Test;
15
import org.openqa.selenium.By;
16
import org.openqa.selenium.RenderedWebElement;
17
import org.openqa.selenium.WebElement;
18

  
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
22

  
23
@DataPortalContexts( { DataPortalContext.cichorieae })
24
public class CichorieaeSearchTest extends CdmDataPortalTestBase {
25

  
26
	@Test
27
	public void testSearchLCommunis() throws Exception {
28
		driver.get(getBaseUrl()
29
						+ "?query=Lapsana+com*&search[tree]=534e190f-3339-49ba-95d9-fa27d5493e3e&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
30
		WebElement taxonElement = driver.findElement(By
31
				.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[@ref='/name/f280f79f-5903-47b0-8352-53e4204c6cf1']"));
32

  
33
		WebElement nameElement = taxonElement.findElement(By.className("BotanicalName"));
34

  
35
		RenderedWebElement namePart1 = (RenderedWebElement) nameElement.findElement(By.xpath("span[1]"));
36
		Assert.assertEquals("Lapsana", namePart1.getText());
37
		Assert.assertEquals("italic", namePart1.getValueOfCssProperty("font-style"));
38

  
39
		RenderedWebElement namePart2 = (RenderedWebElement) nameElement.findElement(By.xpath("span[2]"));
40
		Assert.assertEquals("communis", namePart2.getText());
41
		Assert.assertEquals("italic", namePart2.getValueOfCssProperty("font-style"));
42

  
43
		RenderedWebElement authorPart = (RenderedWebElement) nameElement.findElement(By.xpath("span[3]"));
44
		Assert.assertEquals("L.", authorPart.getText());
45
		Assert.assertEquals("normal", authorPart.getValueOfCssProperty("font-style"));
46

  
47
		RenderedWebElement referenceElement = (RenderedWebElement) taxonElement.findElement(By.className("reference"));
48
		Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
49
	}
50

  
51
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Allium_guttatum_subsp_guttatum_TaxonProfileTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests.cyprus;
11

  
12
import static org.junit.Assert.*;
13

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

  
18
import org.junit.After;
19
import org.junit.Before;
20
import org.junit.Test;
21
import org.openqa.selenium.By;
22
import org.openqa.selenium.WebElement;
23

  
24
import eu.etaxonomy.dataportal.DataPortalContext;
25
import eu.etaxonomy.dataportal.elements.FeatureBlock;
26
import eu.etaxonomy.dataportal.elements.ImgElement;
27
import eu.etaxonomy.dataportal.elements.LinkElement;
28
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
29
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
30
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
31

  
32
/**
33
 * @author a.kohlbecker
34
 *
35
 */
36

  
37
@DataPortalContexts( { DataPortalContext.cyprus })
38
public class Allium_guttatum_subsp_guttatum_TaxonProfileTest extends CdmDataPortalTestBase{
39

  
40
	static UUID taxonUuid = UUID.fromString("6d04598b-3852-4038-91c9-13c7581b21a6");
41

  
42
	TaxonProfilePage p = null;
43

  
44
	@Before
45
	public void setUp() throws MalformedURLException {
46

  
47
		p = new TaxonProfilePage(driver, getContext(), taxonUuid);
48

  
49
	}
50

  
51
	@After
52
	public void tearDown(){
53
		logger.debug("@After");
54
	}
55

  
56

  
57
	@Test
58
	public void testPage() {
59

  
60
		assertEquals(prepareTitle("Allium guttatum subsp. guttatum"), p.getTitle());
61
		assertNull("Authorship information should be hidden", p.getAuthorInformationText());
62

  
63
		List<LinkElement> primaryTabs = p.getPrimaryTabs();
64
		assertEquals("Expecting 3 tabs", 3, primaryTabs.size());
65
		assertEquals("General", primaryTabs.get(0).getText());
66
		assertEquals("Synonymy", primaryTabs.get(1).getText());
67
		assertEquals("Images", primaryTabs.get(2).getText());
68

  
69
		ImgElement profileImage = p.getProfileImage();
70
		assertNotNull("Expecting profile images to be switched on", profileImage);
71
		assertEquals("http://media.bgbm.org/erez/erez?src=EditWP6/zypern/photos/Allium_guttatum_guttatum_A1.jpg", profileImage.getUrl().toString());
72
		assertEquals(400, profileImage.getDimension().getHeight(), 0.5);
73
		assertEquals(250, profileImage.getDimension().getWidth(), 0.5);
74

  
75
		assertEquals("Content", p.getTableOfContentHeader());
76
		List<LinkElement> links = p.getTableOfContentLinks();
77
		assertNotNull("Expecting a list of TOC links in the profile page.", links);
78
		subtestTableOfContentEntry(0, "Status", "status");
79
		subtestTableOfContentEntry(1, "Endemism", "endemism");
80
		subtestTableOfContentEntry(2, "Red Data Book category", "red_data_book_category");
81
		subtestTableOfContentEntry(3, "Systematics", "systematics");
82
		subtestTableOfContentEntry(4, "Distribution", "distribution");
83

  
84
		FeatureBlock featureBlock = p.getFeatureBlockAt(0, "status", "div", "div");
85
		assertEquals("Status\nIndigenous (IN)", featureBlock.getText());
86

  
87
		featureBlock = p.getFeatureBlockAt(1, "endemism", "div", "div");
88
		assertEquals("Endemism\nnot endemic", featureBlock.getText());
89

  
90
		featureBlock = p.getFeatureBlockAt(2, "red_data_book_category", "div", "div");
91
		assertEquals("Red Data Book category\nData deficient (DD)", featureBlock.getText());
92

  
93
		//FIXME
94
//		featureBlock = p.getFeatureBlockAt(2, "systematics", "div", null);
95
//		assertEquals("Systematics\nTaxonomy and nomenclature follow Mathew (1996).\nMathew B. 1996: A review of Allium section Allium . - Kew.", featureBlock.getText());
96

  
97
		featureBlock = p.getFeatureBlockAt(4, "distribution", "div", "span");
98
		assertEquals("Distribution Division 2 1 1. R. D. Meikle, Flora of Cyprus 1. 1977", featureBlock.getText());
99
		assertEquals("Distribution", featureBlock.getHeader());
100
		assertEquals("expecting one footnote key", 1, featureBlock.getFootNoteKeys().size());
101
		assertTrue("expecting one footnote 0 to be the footnote for key 0",featureBlock.getFootNotes().get(0).startsWith(featureBlock.getFootNoteKeys().get(0)));
102
		assertEquals("1. R. D. Meikle, Flora of Cyprus 1. 1977", featureBlock.getFootNotes().get(0));
103
		WebElement distributionMapImage = featureBlock.getElement().findElement(By.className("distribution_map"));
104
		assertEquals("http://edit.br.fgov.be/edit_wp5/v1.1/rest_gen.php?title=a:Indigenous&ad=cyprusdivs:bdcode:a:2&as=z:ffffff,606060,,|y:1874CD,,|a:339966,,0.1,&l=background_gis:y,cyprusdivs:z&ms=500&bbox=32,34,35,36&label=1&img=true&legend=1&mlp=3&mc_s=Georgia,15,blue&mc=&recalculate=false", distributionMapImage.getAttribute("src"));
105

  
106
	}
107

  
108

  
109
	/**
110
	 * @param index
111
	 * @param tocLinkText
112
	 * @param tocLinkFragment
113
	 */
114
	private void subtestTableOfContentEntry(int index, String tocLinkText, String tocLinkFragment) {
115
		assertEquals(tocLinkText, p.getTableOfContentLinks().get(index).getText());
116
		String expectedHref = p.getDrupalPagePath() + "#" + tocLinkFragment;
117
		assertTrue("Expecting the toc link to end with " + expectedHref,  p.getTableOfContentLinks().get(index).getUrl().toString().endsWith(expectedHref));
118
	}
119

  
120
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/CyprusSearchTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests.cyprus;
11

  
12
import org.junit.Assert;
13
import org.junit.Ignore;
14
import org.junit.Test;
15
import org.openqa.selenium.By;
16
import org.openqa.selenium.RenderedWebElement;
17
import org.openqa.selenium.WebElement;
18

  
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
22

  
23
/**
24
 * @author a.kohlbecker
25
 *
26
 */
27

  
28
@DataPortalContexts( { DataPortalContext.cyprus })
29
public class CyprusSearchTest extends CdmDataPortalTestBase{
30

  
31
	/**
32
	 * see http://dev.e-taxonomy.eu/trac/ticket/2350
33
	 */
34
	@Test
35
	@Ignore
36
	public void searchResultsWithoutAnnotationFootnotes(){
37
		driver.get(getBaseUrl() + "?query=Genis*&search[tree]=0c2b5d25-7b15-4401-8b51-dd4be0ee5cab&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
38

  
39
		// --- This variant is slower in FF that using the full xpath
40
		//		WebElement container = driver.findElement(By.id("squeeze"));
41
		//		RenderedWebElement element = (RenderedWebElement)container.findElement(By.xpath("div/div/ul/li/span[contains(@class, 'footnote-key')]"));
42

  
43
		// --- using the full xpath
44
		RenderedWebElement element = (RenderedWebElement)driver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[contains(@class, 'footnote-key')]"));
45
		Assert.assertNull("result set entries must not have footnote keys", element);
46
	}
47

  
48
}
modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/flMalesiana/FloraMalesianaPolytomousKeyTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 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.selenium.tests.flMalesiana;
11

  
12
import java.net.MalformedURLException;
13
import java.util.UUID;
14

  
15
import org.junit.Assert;
16
import org.junit.Test;
17
import org.openqa.selenium.support.PageFactory;
18

  
19
import eu.etaxonomy.dataportal.DataPortalContext;
20
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
21
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
22
import eu.etaxonomy.dataportal.pages.PolytomousKeyPage;
23
import eu.etaxonomy.dataportal.pages.PolytomousKeyPage.KeyLineData;
24
import eu.etaxonomy.dataportal.pages.PolytomousKeyPage.LinkClass;
25
import eu.etaxonomy.dataportal.pages.PortalPage;
26

  
27
/**
28
 * @author a.kohlbecker
29
 *
30
 */
31

  
32
@DataPortalContexts({ DataPortalContext.floramalesiana })
33
public class FloraMalesianaPolytomousKeyTest extends CdmDataPortalTestBase {
34

  
35
	/**
36
	 * see http://dev.e-taxonomy.eu/trac/ticket/2350
37
	 * @throws MalformedURLException
38
	 *
39
	 */
40
	@Test
41
	public void key_to_Malaysian_Sapindaceae_Genera() throws MalformedURLException {
42

  
43
		UUID keyUuid = UUID.fromString("40cf3253-ce7a-4ad6-9a32-27695c36eb5d");
44

  
45
		PolytomousKeyPage p = new PolytomousKeyPage(driver, getContext(), keyUuid);
46

  
47
		PortalPage targetPage;
48
		KeyLineData keyLineData;
49

  
50

  
51
		Assert.assertEquals(prepareTitle("KEY I TO THE MALESIAN GENERA (based on vegetative and flower characters) (F. Adema)"), p.getTitle());
52

  
53
		// -------- //
54
		keyLineData = new KeyLineData("0",
55
				"Trees or shrubs, exceptionally lianas. Leaves simple, unifoliolate, (bi)pinnate or digitate. Inflorescences without basal tendrils",
56
				LinkClass.nodeLinkToNode, "1");
57
		targetPage = p.followPolytomousKeyLine(0, keyLineData);
58
		Assert.assertEquals(p, targetPage);
59

  
60
		// -------- //
61
		keyLineData = new KeyLineData("0'", "Herbaceous or woody climbers. Leaves biternate. Inflorescences with basal tendrils",
62
				LinkClass.nodeLinkToTaxon, "Cardiospermum");
63
		targetPage = p.followPolytomousKeyLine(1, keyLineData);
64
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
65
		p.get();
66

  
67
		// -------- //
68
		keyLineData = new KeyLineData("1", "Leaves simple, unifoliolate, (im)paripinnate or digitate", LinkClass.nodeLinkToNode, "2");
69
		targetPage = p.followPolytomousKeyLine(2, keyLineData);
70
		Assert.assertEquals(p, targetPage);
71

  
72
		// -------- //
73
		keyLineData = new KeyLineData("1'", "Leaves bipinnate", LinkClass.nodeLinkToTaxon, "Tristiropsis");
74
		targetPage = p.followPolytomousKeyLine(3, keyLineData);
75
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
76
		p.get();
77

  
78
		// -------- //
79
		keyLineData = new KeyLineData(
80
				"116",
81
				"Leaflets entire or crenulate, lower surface without small glands. Inflorescences axillary, sometimes together pseudoterminal; cymes dense, many-flowered",
82
				LinkClass.nodeLinkToTaxon, "Synima cordierorum");
83
		targetPage = p.followPolytomousKeyLine(126, keyLineData);
84
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
85
		p.get();
86

  
87
		// -------- //
88
		keyLineData = new KeyLineData(
89
				"116'",
90
				"Leaflets entire, lower surface usually with small glands. Inflorescences axillary, together mostly pseudoterminal, by the shifting aside and suppression of the terminal bud sometimes seemingly truly terminal; cymes lax, 1- or few-flowered",
91
				LinkClass.nodeLinkToTaxon, "Trigonachras");
92
		targetPage = p.followPolytomousKeyLine(127, keyLineData);
93
		Assert.assertEquals(prepareTitle(keyLineData.getLinkText()), targetPage.getTitle());
94

  
95
	}
96

  
97
}

Also available in: Unified diff