Revision a5594ab7
Added by Alex Theys almost 12 years ago
.gitattributes | ||
---|---|---|
264 | 264 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfiguration.java -text |
265 | 265 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/TestConfigurationException.java -text |
266 | 266 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/BaseElement.java -text |
267 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/ClassificationTreeBlock.java -text |
|
268 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/ClassificationTreeElement.java -text |
|
267 | 269 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/DescriptionElementRepresentation.java -text |
268 | 270 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/DrupalBlock.java -text |
269 | 271 |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java -text |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/pom.xml | ||
---|---|---|
12 | 12 |
|
13 | 13 |
<properties> |
14 | 14 |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
15 |
<selenium-version>2.6.0</selenium-version>
|
|
15 |
<selenium-version>2.21.0</selenium-version>
|
|
16 | 16 |
</properties> |
17 | 17 |
|
18 | 18 |
<scm> |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/ClassificationTreeBlock.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2012 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.Dimension; |
|
14 |
import org.openqa.selenium.Point; |
|
15 |
import org.openqa.selenium.WebElement; |
|
16 |
import org.openqa.selenium.remote.RemoteWebElement; |
|
17 |
|
|
18 |
import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl; |
|
19 |
|
|
20 |
/** |
|
21 |
* |
|
22 |
* <div class="cdm_taxontree_scroller_xy"> |
|
23 |
* <ul class="cdm_taxontree"><li |
|
24 |
* |
|
25 |
* @author andreas |
|
26 |
* @date May 21, 2012 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class ClassificationTreeBlock extends DrupalBlock { |
|
30 |
|
|
31 |
private ClassificationTreeElement focusedElement; |
|
32 |
|
|
33 |
private RemoteWebElement viewPortElement; |
|
34 |
|
|
35 |
public ClassificationTreeElement getFocusedElement(){ |
|
36 |
return focusedElement; |
|
37 |
} |
|
38 |
|
|
39 |
public ClassificationTreeBlock(WebElement element) { |
|
40 |
super(element); |
|
41 |
|
|
42 |
focusedElement = new ClassificationTreeElement(element.findElement(By.className("focused"))); |
|
43 |
viewPortElement = (RemoteWebElement)element.findElement(By.className("cdm_taxontree_scroller_xy")); |
|
44 |
} |
|
45 |
|
|
46 |
public Point positionInViewPort(ClassificationTreeElement element){ |
|
47 |
Point elementLocation = ((RemoteWebElement)element.getElement()).getLocationOnScreenOnceScrolledIntoView(); |
|
48 |
Point viewPortLocation = viewPortElement.getLocationOnScreenOnceScrolledIntoView(); |
|
49 |
return new Point(elementLocation.x - viewPortLocation.x, elementLocation.y - viewPortLocation.y); |
|
50 |
} |
|
51 |
|
|
52 |
public boolean isVisibleInViewPort(ClassificationTreeElement element){ |
|
53 |
Point elementOffset = positionInViewPort(element); |
|
54 |
Dimension viewPortDimension = viewPortElement.getSize(); |
|
55 |
return elementOffset.y < viewPortDimension.height; |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
} |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/ClassificationTreeElement.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2012 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.WebElement; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author andreas |
|
17 |
* @date May 21, 2012 |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class ClassificationTreeElement extends BaseElement { |
|
21 |
|
|
22 |
|
|
23 |
private String taxonName; |
|
24 |
|
|
25 |
private String linkUrl; |
|
26 |
|
|
27 |
|
|
28 |
private boolean isFocused; |
|
29 |
|
|
30 |
public String getTaxonName() { |
|
31 |
return taxonName; |
|
32 |
} |
|
33 |
|
|
34 |
public String getLinkUrl() { |
|
35 |
return linkUrl; |
|
36 |
} |
|
37 |
|
|
38 |
public boolean isFocused() { |
|
39 |
return isFocused; |
|
40 |
} |
|
41 |
|
|
42 |
public ClassificationTreeElement(WebElement element) { |
|
43 |
super(element); |
|
44 |
taxonName = element.getText(); |
|
45 |
for(String classAttribute : getClassAttributes()){ |
|
46 |
if(classAttribute.equals("focused")){ |
|
47 |
isFocused = true; |
|
48 |
break; |
|
49 |
} |
|
50 |
} |
|
51 |
linkUrl = element.findElement(By.tagName("a")).getAttribute("href"); |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
} |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/GenericPortalPage.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.net.MalformedURLException; |
13 | 13 |
import java.sql.PreparedStatement; |
14 |
import java.util.List; |
|
14 | 15 |
|
16 |
import org.junit.Assert; |
|
15 | 17 |
import org.openqa.selenium.By; |
16 | 18 |
import org.openqa.selenium.WebDriver; |
19 |
import org.openqa.selenium.WebElement; |
|
17 | 20 |
|
18 | 21 |
import com.google.common.base.Function; |
19 | 22 |
|
20 | 23 |
import eu.etaxonomy.dataportal.DataPortalContext; |
24 |
import eu.etaxonomy.dataportal.elements.ClassificationTreeBlock; |
|
21 | 25 |
import eu.etaxonomy.dataportal.selenium.AllTrue; |
22 | 26 |
import eu.etaxonomy.dataportal.selenium.PageTitleValidated; |
23 | 27 |
import eu.etaxonomy.dataportal.selenium.UrlLoaded; |
... | ... | |
31 | 35 |
public class GenericPortalPage extends PortalPage { |
32 | 36 |
|
33 | 37 |
|
34 |
/**
|
|
35 |
* @param driver
|
|
36 |
* @param context
|
|
37 |
* @param pagePathSuffix
|
|
38 |
* @throws MalformedURLException
|
|
39 |
*/
|
|
40 |
public GenericPortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException {
|
|
41 |
super(driver, context, pagePathSuffix);
|
|
42 |
}
|
|
38 |
/**
|
|
39 |
* @param driver
|
|
40 |
* @param context
|
|
41 |
* @param pagePathSuffix
|
|
42 |
* @throws MalformedURLException
|
|
43 |
*/
|
|
44 |
public GenericPortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException {
|
|
45 |
super(driver, context, pagePathSuffix);
|
|
46 |
}
|
|
43 | 47 |
|
44 |
/**
|
|
45 |
* @param driver
|
|
46 |
* @param context
|
|
47 |
* @throws Exception
|
|
48 |
*/
|
|
49 |
public GenericPortalPage(WebDriver driver, DataPortalContext context) throws Exception {
|
|
50 |
super(driver, context);
|
|
51 |
}
|
|
48 |
/**
|
|
49 |
* @param driver
|
|
50 |
* @param context
|
|
51 |
* @throws Exception
|
|
52 |
*/
|
|
53 |
public GenericPortalPage(WebDriver driver, DataPortalContext context) throws Exception {
|
|
54 |
super(driver, context);
|
|
55 |
}
|
|
52 | 56 |
|
53 |
protected static String drupalPagePathBase = "cdm_dataportal";
|
|
57 |
protected static String drupalPagePathBase = "cdm_dataportal";
|
|
54 | 58 |
|
55 |
/* (non-Javadoc)
|
|
56 |
* @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
|
|
57 |
*/
|
|
58 |
@Override
|
|
59 |
protected String getDrupalPageBase() {
|
|
60 |
return drupalPagePathBase;
|
|
61 |
}
|
|
59 |
/* (non-Javadoc)
|
|
60 |
* @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
|
|
61 |
*/
|
|
62 |
@Override
|
|
63 |
protected String getDrupalPageBase() {
|
|
64 |
return drupalPagePathBase;
|
|
65 |
}
|
|
62 | 66 |
|
63 |
public TaxonSearchResultPage submitQuery(String query) throws Exception{
|
|
64 |
searchBlockElement.findElement(By.id("edit-query")).clear();
|
|
65 |
searchBlockElement.findElement(By.id("edit-query")).sendKeys(query);
|
|
66 |
searchBlockElement.findElement(By.id("edit-submit")).submit();//Search results
|
|
67 |
public TaxonSearchResultPage submitQuery(String query) throws Exception{
|
|
68 |
searchBlockElement.findElement(By.id("edit-query")).clear();
|
|
69 |
searchBlockElement.findElement(By.id("edit-query")).sendKeys(query);
|
|
70 |
searchBlockElement.findElement(By.id("edit-submit")).submit();//Search results
|
|
67 | 71 |
|
68 |
wait.until(new AllTrue(new PageTitleValidated(context.prepareTitle("Search results")), new VisibilityOfElementLocated(By.id("container"))));
|
|
69 |
return new TaxonSearchResultPage(driver, context);
|
|
70 |
}
|
|
72 |
wait.until(new AllTrue(new PageTitleValidated(context.prepareTitle("Search results")), new VisibilityOfElementLocated(By.id("container"))));
|
|
73 |
return new TaxonSearchResultPage(driver, context);
|
|
74 |
}
|
|
71 | 75 |
|
72 | 76 |
} |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import eu.etaxonomy.dataportal.DataPortalContext; |
25 | 25 |
import eu.etaxonomy.dataportal.elements.BaseElement; |
26 |
import eu.etaxonomy.dataportal.elements.ClassificationTreeBlock; |
|
26 | 27 |
import eu.etaxonomy.dataportal.elements.LinkElement; |
27 | 28 |
import eu.etaxonomy.dataportal.selenium.JUnitWebDriverWait; |
28 | 29 |
import eu.etaxonomy.dataportal.selenium.UrlLoaded; |
29 | 30 |
|
30 | 31 |
public abstract class PortalPage { |
31 | 32 |
|
32 |
/**
|
|
33 |
*
|
|
34 |
*/
|
|
35 |
public static final int WAIT_SECONDS = 25;
|
|
33 |
/**
|
|
34 |
*
|
|
35 |
*/
|
|
36 |
public static final int WAIT_SECONDS = 25;
|
|
36 | 37 |
|
37 |
public static final Logger logger = Logger.getLogger(PortalPage.class);
|
|
38 |
public static final Logger logger = Logger.getLogger(PortalPage.class);
|
|
38 | 39 |
|
39 |
protected final static String DRUPAL_PAGE_QUERY_BASE = "?q=";
|
|
40 |
protected final static String DRUPAL_PAGE_QUERY_BASE = "?q=";
|
|
40 | 41 |
|
41 |
protected WebDriver driver;
|
|
42 |
protected WebDriver driver;
|
|
42 | 43 |
|
43 |
protected DataPortalContext context;
|
|
44 |
protected DataPortalContext context;
|
|
44 | 45 |
|
45 |
protected final JUnitWebDriverWait wait;
|
|
46 |
protected final JUnitWebDriverWait wait;
|
|
46 | 47 |
|
47 |
public WebDriverWait getWait() {
|
|
48 |
return wait;
|
|
49 |
}
|
|
48 |
public WebDriverWait getWait() {
|
|
49 |
return wait;
|
|
50 |
}
|
|
50 | 51 |
|
51 | 52 |
|
52 |
/**
|
|
53 |
* Implementations of this method will supply the relative
|
|
54 |
* path to the Drupal page. This path will usally have the form
|
|
55 |
* <code>cdm_dataportal/{nodetype}</code>. For example the taxon pages all
|
|
56 |
* have the page base <code>cdm_dataportal/taxon</code>
|
|
57 |
* @return
|
|
58 |
*/
|
|
59 |
protected abstract String getDrupalPageBase();
|
|
53 |
/**
|
|
54 |
* Implementations of this method will supply the relative
|
|
55 |
* path to the Drupal page. This path will usally have the form
|
|
56 |
* <code>cdm_dataportal/{nodetype}</code>. For example the taxon pages all
|
|
57 |
* have the page base <code>cdm_dataportal/taxon</code>
|
|
58 |
* @return
|
|
59 |
*/
|
|
60 |
protected abstract String getDrupalPageBase();
|
|
60 | 61 |
|
61 |
private String drupalPagePath;
|
|
62 |
private String drupalPagePath;
|
|
62 | 63 |
|
63 |
protected URL pageUrl;
|
|
64 |
protected URL pageUrl;
|
|
64 | 65 |
|
65 |
// ==== WebElements === //
|
|
66 |
// ==== WebElements === //
|
|
66 | 67 |
|
67 |
@FindBy(id="cdm_dataportal.node")
|
|
68 |
protected WebElement portalContent;
|
|
68 |
@FindBy(id="cdm_dataportal.node")
|
|
69 |
protected WebElement portalContent;
|
|
69 | 70 |
|
70 |
@FindBy(tagName="title")
|
|
71 |
@CacheLookup
|
|
72 |
protected WebElement title;
|
|
71 |
@FindBy(tagName="title")
|
|
72 |
@CacheLookup
|
|
73 |
protected WebElement title;
|
|
73 | 74 |
|
74 |
@FindBy(className="node")
|
|
75 |
protected WebElement node;
|
|
75 |
@FindBy(className="node")
|
|
76 |
protected WebElement node;
|
|
76 | 77 |
|
77 |
@FindBys({@FindBy(id="tabs-wrapper"), @FindBy(className="primary")})
|
|
78 |
@CacheLookup
|
|
79 |
protected WebElement primaryTabs;
|
|
78 |
@FindBys({@FindBy(id="tabs-wrapper"), @FindBy(className="primary")})
|
|
79 |
@CacheLookup
|
|
80 |
protected WebElement primaryTabs;
|
|
80 | 81 |
|
81 |
@FindBy(id="block-cdm_dataportal-2")
|
|
82 |
@CacheLookup
|
|
83 |
protected WebElement searchBlockElement;
|
|
82 |
@FindBy(id="block-cdm_dataportal-2")
|
|
83 |
@CacheLookup
|
|
84 |
protected WebElement searchBlockElement;
|
|
84 | 85 |
|
85 |
@FindBy(id="block-cdm_taxontree-cdm_tree")
|
|
86 |
@CacheLookup
|
|
87 |
protected WebElement classificationBrowserBlock;
|
|
86 |
@FindBy(id="block-cdm_taxontree-cdm_tree")
|
|
87 |
@CacheLookup
|
|
88 |
protected WebElement classificationBrowserBlock;
|
|
88 | 89 |
|
89 |
/**
|
|
90 |
* Creates a new PortaPage. Implementations of this class will provide the base path of the page by
|
|
91 |
* implementing the method {@link #getDrupalPageBase()}. The constructor argument <code>pagePathSuffix</code>
|
|
92 |
* specifies the specific page to navigate to. For example:
|
|
93 |
* <ol>
|
|
94 |
* <li>{@link #getDrupalPageBase()} returns <code>/cdm_dataportal/taxon</code></li>
|
|
95 |
* <li><code>pagePathSuffix</code> gives <code>7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code></li>
|
|
96 |
* </ol>
|
|
97 |
* Both are combined to form the URL pathelement <code>/cdm_dataportal/taxon/7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code>
|
|
98 |
*
|
|
99 |
*
|
|
100 |
* @param driver
|
|
101 |
* @param context
|
|
102 |
* @param pagePathSuffix
|
|
103 |
* @throws MalformedURLException
|
|
104 |
*/
|
|
105 |
public PortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException {
|
|
90 |
/**
|
|
91 |
* Creates a new PortaPage. Implementations of this class will provide the base path of the page by
|
|
92 |
* implementing the method {@link #getDrupalPageBase()}. The constructor argument <code>pagePathSuffix</code>
|
|
93 |
* specifies the specific page to navigate to. For example:
|
|
94 |
* <ol>
|
|
95 |
* <li>{@link #getDrupalPageBase()} returns <code>/cdm_dataportal/taxon</code></li>
|
|
96 |
* <li><code>pagePathSuffix</code> gives <code>7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code></li>
|
|
97 |
* </ol>
|
|
98 |
* Both are combined to form the URL pathelement <code>/cdm_dataportal/taxon/7fe8a8b6-b0ba-4869-90b3-177b76c1753f</code>
|
|
99 |
*
|
|
100 |
*
|
|
101 |
* @param driver
|
|
102 |
* @param context
|
|
103 |
* @param pagePathSuffix
|
|
104 |
* @throws MalformedURLException
|
|
105 |
*/
|
|
106 |
public PortalPage(WebDriver driver, DataPortalContext context, String pagePathSuffix) throws MalformedURLException {
|
|
106 | 107 |
|
107 |
this.driver = driver;
|
|
108 |
this.driver = driver;
|
|
108 | 109 |
|
109 |
this.context = context;
|
|
110 |
this.context = context;
|
|
110 | 111 |
|
111 |
this.wait = new JUnitWebDriverWait(driver, WAIT_SECONDS);
|
|
112 |
this.wait = new JUnitWebDriverWait(driver, WAIT_SECONDS);
|
|
112 | 113 |
|
113 |
this.drupalPagePath = getDrupalPageBase() + (pagePathSuffix != null ? "/" + pagePathSuffix: "");
|
|
114 |
this.drupalPagePath = getDrupalPageBase() + (pagePathSuffix != null ? "/" + pagePathSuffix: "");
|
|
114 | 115 |
|
115 |
this.pageUrl = new URL(context.getBaseUri().toString() + DRUPAL_PAGE_QUERY_BASE + drupalPagePath);
|
|
116 |
this.pageUrl = new URL(context.getBaseUri().toString() + DRUPAL_PAGE_QUERY_BASE + drupalPagePath);
|
|
116 | 117 |
|
117 |
// tell browser to navigate to the page
|
|
118 |
driver.get(pageUrl.toString());
|
|
118 |
// tell browser to navigate to the page
|
|
119 |
driver.get(pageUrl.toString());
|
|
119 | 120 |
|
120 |
// This call sets the WebElement fields.
|
|
121 |
PageFactory.initElements(driver, this);
|
|
121 |
// This call sets the WebElement fields.
|
|
122 |
PageFactory.initElements(driver, this);
|
|
122 | 123 |
|
123 |
logger.info("loading " + pageUrl);
|
|
124 |
logger.info("loading " + pageUrl);
|
|
124 | 125 |
|
125 |
}
|
|
126 |
}
|
|
126 | 127 |
|
127 |
/**
|
|
128 |
* Creates a new PortaPage at given URL location. An Exception is thrown if
|
|
129 |
* this URL is not matching the expected URL for the specific page type.
|
|
130 |
*
|
|
131 |
* @param driver
|
|
132 |
* @param context
|
|
133 |
* @param url
|
|
134 |
* @throws Exception
|
|
135 |
*/
|
|
136 |
public PortalPage(WebDriver driver, DataPortalContext context, URL url) throws Exception {
|
|
128 |
/**
|
|
129 |
* Creates a new PortaPage at given URL location. An Exception is thrown if
|
|
130 |
* this URL is not matching the expected URL for the specific page type.
|
|
131 |
*
|
|
132 |
* @param driver
|
|
133 |
* @param context
|
|
134 |
* @param url
|
|
135 |
* @throws Exception
|
|
136 |
*/
|
|
137 |
public PortalPage(WebDriver driver, DataPortalContext context, URL url) throws Exception {
|
|
137 | 138 |
|
138 |
this.driver = driver;
|
|
139 |
this.driver = driver;
|
|
139 | 140 |
|
140 |
this.context = context;
|
|
141 |
this.context = context;
|
|
141 | 142 |
|
142 |
this.wait = new JUnitWebDriverWait(driver, 25);
|
|
143 |
this.wait = new JUnitWebDriverWait(driver, 25);
|
|
143 | 144 |
|
144 |
this.pageUrl = new URL(context.getBaseUri().toString());
|
|
145 |
this.pageUrl = new URL(context.getBaseUri().toString());
|
|
145 | 146 |
|
146 |
// tell browser to navigate to the given URL
|
|
147 |
driver.get(url.toString());
|
|
147 |
// tell browser to navigate to the given URL
|
|
148 |
driver.get(url.toString());
|
|
148 | 149 |
|
149 |
if(!isOnPage()){
|
|
150 |
throw new Exception("Not on the expected portal page ( current: " + driver.getCurrentUrl() + ", expected: " + pageUrl + " )");
|
|
151 |
}
|
|
150 |
if(!isOnPage()){
|
|
151 |
throw new Exception("Not on the expected portal page ( current: " + driver.getCurrentUrl() + ", expected: " + pageUrl + " )");
|
|
152 |
}
|
|
152 | 153 |
|
153 |
this.pageUrl = url;
|
|
154 |
this.pageUrl = url;
|
|
154 | 155 |
|
155 |
logger.info("loading " + pageUrl);
|
|
156 |
logger.info("loading " + pageUrl);
|
|
156 | 157 |
|
157 |
// This call sets the WebElement fields.
|
|
158 |
PageFactory.initElements(driver, this);
|
|
158 |
// This call sets the WebElement fields.
|
|
159 |
PageFactory.initElements(driver, this);
|
|
159 | 160 |
|
160 |
}
|
|
161 |
}
|
|
161 | 162 |
|
162 |
/** |
|
163 |
* Creates a new PortaPage at the WebDrivers current URL location. An Exception is thrown if |
|
164 |
* driver.getCurrentUrl() is not matching the expected URL for the specific page type. |
|
165 |
* |
|
166 |
* @param driver |
|
167 |
* @param context |
|
168 |
* @throws Exception |
|
169 |
*/ |
|
170 |
public PortalPage(WebDriver driver, DataPortalContext context) throws Exception { |
|
171 |
|
|
172 |
this.driver = driver; |
|
173 |
|
|
174 |
this.context = context; |
|
175 |
|
|
176 |
this.wait = new JUnitWebDriverWait(driver, 25); |
|
177 |
|
|
178 |
// preliminary set the pageUrl to the base path of this page, this is used in the next setp to check if the |
|
179 |
// driver.getCurrentUrl() is a sub path of the base path |
|
180 |
this.pageUrl = new URL(context.getBaseUri().toString()); |
|
181 |
|
|
182 |
if(!isOnPage()){ |
|
183 |
throw new Exception("Not on the expected portal page ( current: " + driver.getCurrentUrl() + ", expected: " + pageUrl + " )"); |
|
184 |
} |
|
185 |
|
|
186 |
// now set the real URL |
|
187 |
this.pageUrl = new URL(driver.getCurrentUrl()); |
|
188 |
|
|
189 |
logger.info("loading " + pageUrl); |
|
190 |
|
|
191 |
// This call sets the WebElement fields. |
|
192 |
PageFactory.initElements(driver, this); |
|
193 |
|
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* @return |
|
198 |
*/ |
|
199 |
protected boolean isOnPage() { |
|
200 |
return driver.getCurrentUrl().startsWith(pageUrl.toString()); |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* navigate and reload the page if not jet there |
|
205 |
*/ |
|
206 |
public void get() { |
|
207 |
if(!driver.getCurrentUrl().equals(pageUrl.toString())){ |
|
208 |
driver.get(pageUrl.toString()); |
|
209 |
wait.until(new UrlLoaded(pageUrl.toString())); |
|
210 |
PageFactory.initElements(driver, this); |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* go back in history |
|
216 |
*/ |
|
217 |
public void back() { |
|
218 |
driver.navigate().back(); |
|
219 |
} |
|
220 |
|
|
221 |
public String getDrupalPagePath() { |
|
222 |
return drupalPagePath; |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
226 |
* returns the string from the <code>title</code> tag. |
|
227 |
* @return |
|
228 |
*/ |
|
229 |
public String getTitle() { |
|
230 |
return title.getText(); |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* returns the warning messages from the Drupal message box |
|
235 |
* @return |
|
236 |
*/ |
|
237 |
public String getWarnings() { |
|
238 |
return null; //TODO unimplemented |
|
239 |
} |
|
240 |
|
|
241 |
/** |
|
242 |
* returns the error messages from the Drupal message box |
|
243 |
* @return |
|
244 |
*/ |
|
245 |
public String getErrors() { |
|
246 |
return null; //TODO unimplemented |
|
247 |
} |
|
248 |
|
|
249 |
public String getAuthorInformationText() { |
|
250 |
|
|
251 |
WebElement authorInformation = null; |
|
252 |
|
|
253 |
try { |
|
254 |
authorInformation = node.findElement(By.className("submitted")); |
|
255 |
} catch (NoSuchElementException e) { |
|
256 |
// IGNORE // |
|
257 |
} |
|
258 |
|
|
259 |
|
|
260 |
if(authorInformation != null){ |
|
261 |
return authorInformation.getText(); |
|
262 |
} else { |
|
263 |
return null; |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
public List<LinkElement> getPrimaryTabs(){ |
|
268 |
List<LinkElement> tabs = new ArrayList<LinkElement>(); |
|
269 |
List<WebElement> links = primaryTabs.findElements(By.tagName("a")); |
|
270 |
for(WebElement a : links) { |
|
271 |
WebElement renderedLink = a; |
|
272 |
if(renderedLink.isDisplayed()){ |
|
273 |
tabs.add(new LinkElement(renderedLink)); |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
277 |
return tabs; |
|
278 |
} |
|
279 |
|
|
280 |
public void hover(WebElement element) { |
|
281 |
Actions actions = new Actions(driver); |
|
282 |
actions.moveToElement(element, 1, 1).perform(); |
|
283 |
logger.debug("hovering"); |
|
284 |
} |
|
285 |
|
|
286 |
|
|
287 |
/** |
|
288 |
* Returns the current URL string from the {@link WebDriver} |
|
289 |
* @return |
|
290 |
*/ |
|
291 |
public URL getPageURL() { |
|
292 |
return pageUrl; |
|
293 |
} |
|
294 |
|
|
295 |
|
|
296 |
/** |
|
297 |
* return the <code>scheme://domain:port</code> part of the initial url of this page. |
|
298 |
* @return |
|
299 |
*/ |
|
300 |
public String getInitialUrlBase() { |
|
301 |
return pageUrl.getProtocol() + "://" + pageUrl.getHost() + pageUrl.getPort(); |
|
302 |
} |
|
303 |
|
|
304 |
public boolean equals(Object obj) { |
|
305 |
if (PortalPage.class.isAssignableFrom(obj.getClass())) { |
|
306 |
PortalPage page = (PortalPage) obj; |
|
307 |
return this.getPageURL().toString().equals(page.getPageURL().toString()); |
|
308 |
|
|
309 |
} else { |
|
310 |
return false; |
|
311 |
} |
|
312 |
} |
|
313 |
|
|
314 |
|
|
315 |
/** |
|
316 |
* @param <T> |
|
317 |
* @param link the link to click |
|
318 |
* @param isTrue see {@link org.openqa.selenium.support.ui.FluentWait#until(Function)} |
|
319 |
* @param type the return type |
|
320 |
* @param duration may be null, if this in null <code>waitUnit</code> will be ignored. |
|
321 |
* @param waitUnit may be null, is ignored if <code>duration</code> is null defaults to {@link TimeUnit.SECONDS} |
|
322 |
* @return |
|
323 |
* @throws SecurityException |
|
324 |
*/ |
|
325 |
public <T extends PortalPage> T clickLink(BaseElement element, Function<? super WebDriver, Boolean> isTrue, Class<T> type, Long duration, TimeUnit waitUnit) { |
|
326 |
|
|
327 |
String targetWindow = null; |
|
328 |
|
|
329 |
|
|
330 |
if(targetWindow == null){ |
|
331 |
if(element instanceof LinkElement){ |
|
332 |
targetWindow = element.getElement().getAttribute("target"); |
|
333 |
} else { |
|
334 |
try { |
|
335 |
targetWindow = element.getElement().findElement(By.xpath("./a[@target]")).getAttribute("target"); |
|
336 |
} catch (NoSuchElementException e) { |
|
337 |
logger.debug("No target window found"); |
|
338 |
/* IGNORE */ |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
} |
|
343 |
|
|
344 |
logger.info("clicking on " + element + (targetWindow == null? "" : " with target window: '" + targetWindow + "'")); |
|
345 |
|
|
346 |
element.getElement().click(); |
|
347 |
if(targetWindow != null){ |
|
348 |
driver.switchTo().window(targetWindow); |
|
349 |
} |
|
350 |
|
|
351 |
try { |
|
352 |
if(duration != null){ |
|
353 |
if(waitUnit == null){ |
|
354 |
waitUnit = TimeUnit.SECONDS; |
|
355 |
} |
|
356 |
wait.withTimeout(duration, waitUnit).until(isTrue); |
|
357 |
} else { |
|
358 |
wait.until(isTrue); |
|
359 |
} |
|
360 |
} catch (AssertionError timeout){ |
|
361 |
logger.info("current WindowHandles:" + driver.getWindowHandles()); |
|
362 |
throw timeout; |
|
363 |
} |
|
364 |
|
|
365 |
|
|
366 |
Constructor<T> constructor; |
|
367 |
T pageInstance; |
|
368 |
try { |
|
369 |
constructor = type.getConstructor(WebDriver.class, DataPortalContext.class); |
|
370 |
pageInstance = constructor.newInstance(driver, context); |
|
371 |
} catch (Exception e) { |
|
372 |
throw new RuntimeException(e); |
|
373 |
} |
|
374 |
return pageInstance; |
|
375 |
} |
|
376 |
|
|
377 |
|
|
378 |
/** |
|
379 |
* @param <T> |
|
380 |
* @param link the link to click |
|
381 |
* @param isTrue see {@link org.openqa.selenium.support.ui.FluentWait#until(Function)} |
|
382 |
* @param type the return type |
|
383 |
* @return |
|
384 |
*/ |
|
385 |
public <T extends PortalPage> T clickLink(BaseElement element, Function<? super WebDriver, Boolean> isTrue, Class<T> type) { |
|
386 |
return clickLink(element, isTrue, type, null, null); |
|
387 |
} |
|
163 |
/** |
|
164 |
* Creates a new PortaPage at the WebDrivers current URL location. An Exception is thrown if |
|
165 |
* driver.getCurrentUrl() is not matching the expected URL for the specific page type. |
|
166 |
* |
|
167 |
* @param driver |
|
168 |
* @param context |
|
169 |
* @throws Exception |
|
170 |
*/ |
|
171 |
public PortalPage(WebDriver driver, DataPortalContext context) throws Exception { |
|
172 |
|
|
173 |
this.driver = driver; |
|
174 |
|
|
175 |
this.context = context; |
|
176 |
|
|
177 |
this.wait = new JUnitWebDriverWait(driver, 25); |
|
178 |
|
|
179 |
// preliminary set the pageUrl to the base path of this page, this is used in the next setp to check if the |
|
180 |
// driver.getCurrentUrl() is a sub path of the base path |
|
181 |
this.pageUrl = new URL(context.getBaseUri().toString()); |
|
182 |
|
|
183 |
if(!isOnPage()){ |
|
184 |
throw new Exception("Not on the expected portal page ( current: " + driver.getCurrentUrl() + ", expected: " + pageUrl + " )"); |
|
185 |
} |
|
186 |
|
|
187 |
// now set the real URL |
|
188 |
this.pageUrl = new URL(driver.getCurrentUrl()); |
|
189 |
|
|
190 |
logger.info("loading " + pageUrl); |
|
191 |
|
|
192 |
// This call sets the WebElement fields. |
|
193 |
PageFactory.initElements(driver, this); |
|
194 |
|
|
195 |
} |
|
196 |
|
|
197 |
/** |
|
198 |
* @return |
|
199 |
*/ |
|
200 |
protected boolean isOnPage() { |
|
201 |
return driver.getCurrentUrl().startsWith(pageUrl.toString()); |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* navigate and reload the page if not jet there |
|
206 |
*/ |
|
207 |
public void get() { |
|
208 |
if(!driver.getCurrentUrl().equals(pageUrl.toString())){ |
|
209 |
driver.get(pageUrl.toString()); |
|
210 |
wait.until(new UrlLoaded(pageUrl.toString())); |
|
211 |
PageFactory.initElements(driver, this); |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
216 |
* go back in history |
|
217 |
*/ |
|
218 |
public void back() { |
|
219 |
driver.navigate().back(); |
|
220 |
} |
|
221 |
|
|
222 |
public String getDrupalPagePath() { |
|
223 |
return drupalPagePath; |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* returns the string from the <code>title</code> tag. |
|
228 |
* @return |
|
229 |
*/ |
|
230 |
public String getTitle() { |
|
231 |
return title.getText(); |
|
232 |
} |
|
233 |
|
|
234 |
/** |
|
235 |
* returns the warning messages from the Drupal message box |
|
236 |
* @return |
|
237 |
*/ |
|
238 |
public String getWarnings() { |
|
239 |
return null; //TODO unimplemented |
|
240 |
} |
|
241 |
|
|
242 |
/** |
|
243 |
* returns the error messages from the Drupal message box |
|
244 |
* @return |
|
245 |
*/ |
|
246 |
public String getErrors() { |
|
247 |
return null; //TODO unimplemented |
|
248 |
} |
|
249 |
|
|
250 |
public String getAuthorInformationText() { |
|
251 |
|
|
252 |
WebElement authorInformation = null; |
|
253 |
|
|
254 |
try { |
|
255 |
authorInformation = node.findElement(By.className("submitted")); |
|
256 |
} catch (NoSuchElementException e) { |
|
257 |
// IGNORE // |
|
258 |
} |
|
259 |
|
|
260 |
|
|
261 |
if(authorInformation != null){ |
|
262 |
return authorInformation.getText(); |
|
263 |
} else { |
|
264 |
return null; |
|
265 |
} |
|
266 |
} |
|
267 |
|
|
268 |
public List<LinkElement> getPrimaryTabs(){ |
|
269 |
List<LinkElement> tabs = new ArrayList<LinkElement>(); |
|
270 |
List<WebElement> links = primaryTabs.findElements(By.tagName("a")); |
|
271 |
for(WebElement a : links) { |
|
272 |
WebElement renderedLink = a; |
|
273 |
if(renderedLink.isDisplayed()){ |
|
274 |
tabs.add(new LinkElement(renderedLink)); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
return tabs; |
|
279 |
} |
|
280 |
|
|
281 |
public ClassificationTreeBlock getClassificationTree() { |
|
282 |
return new ClassificationTreeBlock(classificationBrowserBlock); |
|
283 |
} |
|
284 |
|
|
285 |
public void hover(WebElement element) { |
|
286 |
Actions actions = new Actions(driver); |
|
287 |
actions.moveToElement(element, 1, 1).perform(); |
|
288 |
logger.debug("hovering"); |
|
289 |
} |
|
290 |
|
|
291 |
|
|
292 |
/** |
|
293 |
* Returns the current URL string from the {@link WebDriver} |
|
294 |
* @return |
|
295 |
*/ |
|
296 |
public URL getPageURL() { |
|
297 |
return pageUrl; |
|
298 |
} |
|
299 |
|
|
300 |
|
|
301 |
/** |
|
302 |
* return the <code>scheme://domain:port</code> part of the initial url of this page. |
|
303 |
* @return |
|
304 |
*/ |
|
305 |
public String getInitialUrlBase() { |
|
306 |
return pageUrl.getProtocol() + "://" + pageUrl.getHost() + pageUrl.getPort(); |
|
307 |
} |
|
308 |
|
|
309 |
public boolean equals(Object obj) { |
|
310 |
if (PortalPage.class.isAssignableFrom(obj.getClass())) { |
|
311 |
PortalPage page = (PortalPage) obj; |
|
312 |
return this.getPageURL().toString().equals(page.getPageURL().toString()); |
|
313 |
|
|
314 |
} else { |
|
315 |
return false; |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
|
|
320 |
/** |
|
321 |
* @param <T> |
|
322 |
* @param link the link to click |
|
323 |
* @param isTrue see {@link org.openqa.selenium.support.ui.FluentWait#until(Function)} |
|
324 |
* @param type the return type |
|
325 |
* @param duration may be null, if this in null <code>waitUnit</code> will be ignored. |
|
326 |
* @param waitUnit may be null, is ignored if <code>duration</code> is null defaults to {@link TimeUnit.SECONDS} |
|
327 |
* @return |
|
328 |
* @throws SecurityException |
|
329 |
*/ |
|
330 |
public <T extends PortalPage> T clickLink(BaseElement element, Function<? super WebDriver, Boolean> isTrue, Class<T> type, Long duration, TimeUnit waitUnit) { |
|
331 |
|
|
332 |
String targetWindow = null; |
|
333 |
|
|
334 |
|
|
335 |
if(targetWindow == null){ |
|
336 |
if(element instanceof LinkElement){ |
|
337 |
targetWindow = element.getElement().getAttribute("target"); |
|
338 |
} else { |
|
339 |
try { |
|
340 |
targetWindow = element.getElement().findElement(By.xpath("./a[@target]")).getAttribute("target"); |
|
341 |
} catch (NoSuchElementException e) { |
|
342 |
logger.debug("No target window found"); |
|
343 |
/* IGNORE */ |
|
344 |
} |
|
345 |
} |
|
346 |
|
|
347 |
} |
|
348 |
|
|
349 |
logger.info("clicking on " + element + (targetWindow == null? "" : " with target window: '" + targetWindow + "'")); |
|
350 |
|
|
351 |
element.getElement().click(); |
|
352 |
if(targetWindow != null){ |
|
353 |
driver.switchTo().window(targetWindow); |
|
354 |
} |
|
355 |
|
|
356 |
try { |
|
357 |
if(duration != null){ |
|
358 |
if(waitUnit == null){ |
|
359 |
waitUnit = TimeUnit.SECONDS; |
|
360 |
} |
|
361 |
wait.withTimeout(duration, waitUnit).until(isTrue); |
|
362 |
} else { |
|
363 |
wait.until(isTrue); |
|
364 |
} |
|
365 |
} catch (AssertionError timeout){ |
|
366 |
logger.info("current WindowHandles:" + driver.getWindowHandles()); |
|
367 |
throw timeout; |
|
368 |
} |
|
369 |
|
|
370 |
|
|
371 |
Constructor<T> constructor; |
|
372 |
T pageInstance; |
|
373 |
try { |
|
374 |
constructor = type.getConstructor(WebDriver.class, DataPortalContext.class); |
|
375 |
pageInstance = constructor.newInstance(driver, context); |
|
376 |
} catch (Exception e) { |
|
377 |
throw new RuntimeException(e); |
|
378 |
} |
|
379 |
return pageInstance; |
|
380 |
} |
|
381 |
|
|
382 |
|
|
383 |
/** |
|
384 |
* @param <T> |
|
385 |
* @param link the link to click |
|
386 |
* @param isTrue see {@link org.openqa.selenium.support.ui.FluentWait#until(Function)} |
|
387 |
* @param type the return type |
|
388 |
* @return |
|
389 |
*/ |
|
390 |
public <T extends PortalPage> T clickLink(BaseElement element, Function<? super WebDriver, Boolean> isTrue, Class<T> type) { |
|
391 |
return clickLink(element, isTrue, type, null, null); |
|
392 |
} |
|
388 | 393 |
|
389 | 394 |
|
390 | 395 |
} |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java | ||
---|---|---|
44 | 44 |
@DataPortalContexts( { DataPortalContext.cichorieae }) |
45 | 45 |
public class Lactuca_triquetra_TaxonProfileTest extends CdmDataPortalTestBase{ |
46 | 46 |
|
47 |
public static final Logger logger = Logger.getLogger(Lactuca_triquetra_TaxonProfileTest.class);
|
|
48 |
|
|
49 |
static UUID taxonUuid = UUID.fromString("ecb7a76e-694a-4706-b1ab-a2eb334173ff");
|
|
50 |
|
|
51 |
TaxonProfilePage p = null;
|
|
52 |
|
|
53 |
@Before
|
|
54 |
public void setUp() throws MalformedURLException {
|
|
55 |
|
|
56 |
if(p != null && driver != null ){
|
|
57 |
logger.debug("TaxonProfilePage p:" + p.getPageURL() + ", driver is at " + driver.getCurrentUrl());
|
|
58 |
}
|
|
59 |
p = new TaxonProfilePage(driver, getContext(), taxonUuid);
|
|
60 |
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
@Test
|
|
65 |
public void testTitleAndTabs() {
|
|
66 |
|
|
67 |
assertEquals(getContext().prepareTitle("Lactuca triquetra"), p.getTitle());
|
|
68 |
assertNull("Authorship information should be hidden", p.getAuthorInformationText());
|
|
69 |
|
|
70 |
List<LinkElement> primaryTabs = p.getPrimaryTabs();
|
|
71 |
int tabId = 0;
|
|
72 |
assertEquals("General", primaryTabs.get(tabId++).getText());
|
|
73 |
assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
|
|
74 |
assertEquals("Images", primaryTabs.get(tabId++).getText());
|
|
75 |
assertEquals("Specimens", primaryTabs.get(tabId++).getText());
|
|
76 |
assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
|
|
77 |
|
|
78 |
}
|
|
79 |
|
|
80 |
@Test
|
|
81 |
public void testProfileImage() {
|
|
82 |
ImgElement profileImage = p.getProfileImage();
|
|
83 |
assertNotNull("Expecting profile images to be switched on", profileImage);
|
|
84 |
assertTrue("Expoecting image Lactuca_triquetra_Bc_01.JPG", profileImage.getSrcUrl().toString().endsWith("/Lactuca_triquetra_Bc_01.JPG"));
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
@Test
|
|
89 |
public void testFeatures() {
|
|
90 |
assertEquals("Content", p.getTableOfContentHeader());
|
|
91 |
List<LinkElement> links = p.getTableOfContentLinks();
|
|
92 |
assertNotNull("Expecting a list of TOC links in the profile page.", links);
|
|
93 |
|
|
94 |
FeatureBlock featureBlock;
|
|
95 |
int featureId = 0;
|
|
96 |
|
|
97 |
int descriptionElementFontSize = 12;
|
|
98 |
String expectedCssDisplay = "inline";
|
|
99 |
String expectedListStyleType = "none";
|
|
100 |
String expectedListStylePosition = "outside";
|
|
101 |
String expectedListStyleImage = "none";
|
|
102 |
int indent = 0;
|
|
103 |
|
|
104 |
/* Description */
|
|
105 |
String featureClass = "description";
|
|
106 |
String featureLabel = "Description";
|
|
107 |
String blockTextFull = null;
|
|
108 |
String blockTextBegin = featureLabel + "\nHerb, perennial, scoparious, 40-80 cm high. Flowering stems erect, triangular, medullary, glaucous-green, soon leafless, strongly branched; branches erect, slender. Cauline leaves few, glabrous.";
|
|
109 |
String blockTextEnd = "Pappus white, 6.0-7.0 mm long, persistent, fragile, shortly barbellate or scabridulous.\n\nbased on: Meikle, R.D. 1985: Flora auf Cyprus 2. - Kew (as Prenanthes triquetra).";
|
|
110 |
expectedListStyleType = "none";
|
|
111 |
|
|
112 |
p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
|
|
113 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
|
114 |
|
|
115 |
assertTrue(featureBlock.getText().startsWith(blockTextBegin));
|
|
116 |
assertTrue(featureBlock.getText().endsWith(blockTextEnd));
|
|
117 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
118 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
119 |
|
|
120 |
/* Distribution */
|
|
121 |
expectedCssDisplay = "block";
|
|
122 |
featureClass = "distribution";
|
|
123 |
featureLabel = "Distribution";
|
|
124 |
blockTextFull = featureLabel + "\n\n\n\nAsia-Temperate:\nCyprus 1,2; Lebanon-Syria (Lebanon 3,4,5); Palestine (Israel 5,6).\n1. Meikle, R. D., Flora of Cyprus 2. 1985, 2. Osorio-Tafall, B. H. & Serafim, G. M., List of the vascular plants of Cyprus. 1973, 3. Mouterde, P., Nouvelle flore du Liban et de la Syrie. Texte 3. 1978-1984, 4. Boissier, E., Flora Orientalis 3. 1875, 5. Post, G. E. , Flora of Syria, Palestine, and Sinai 2. 19336. (N)";
|
|
125 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
126 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
|
|
127 |
|
|
128 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
129 |
|
|
130 |
MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElements().get(0);
|
|
131 |
logger.info(descriptionElement.getText());
|
|
132 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
133 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
134 |
assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size());
|
|
135 |
assertEquals("Expecting 6 Footnotes", 6, featureBlock.getFootNotes().size());
|
|
136 |
|
|
137 |
assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
|
|
138 |
WebElement mapCaptionElement = null;
|
|
139 |
try {
|
|
140 |
mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
|
|
141 |
} catch (NoSuchElementException e){
|
|
142 |
/* IGNORE */
|
|
143 |
}
|
|
144 |
assertNull(mapCaptionElement);
|
|
145 |
|
|
146 |
/* Uses */
|
|
147 |
featureClass = "ecology";
|
|
148 |
featureLabel = "Ecology";
|
|
149 |
blockTextFull = featureLabel + "\n500 m. On chalky cliffs or in flushes on serpentine.\n\nfrom: Meikle, R. D. 1985: Flora of Cyprus 2. – Kew. (as Prenanthes triquetra)";
|
|
150 |
expectedCssDisplay = "inline";
|
|
151 |
|
|
152 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
153 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
|
154 |
|
|
155 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
156 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
157 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
158 |
assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
|
|
159 |
assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
|
|
160 |
|
|
161 |
|
|
162 |
/* Common names */
|
|
163 |
featureClass = "common_names";
|
|
164 |
featureLabel = "Common names";
|
|
165 |
expectedCssDisplay = "block";
|
|
166 |
blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكان7\n7. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000";
|
|
167 |
|
|
168 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
169 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "li");
|
|
170 |
|
|
171 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
172 |
|
|
173 |
|
|
174 |
/* Uses */
|
|
175 |
featureClass = "credits";
|
|
176 |
featureLabel = "Credits";
|
|
177 |
blockTextFull = featureLabel + "\nChristodoulou C. S. 2009: Images (1 added).\nMakris C. 2009: Images (1 added).";
|
|
178 |
expectedCssDisplay = "block";
|
|
179 |
|
|
180 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
181 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
|
182 |
|
|
183 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
184 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
185 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
186 |
assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
|
|
187 |
assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
|
|
188 |
|
|
189 |
}
|
|
47 |
public static final Logger logger = Logger.getLogger(Lactuca_triquetra_TaxonProfileTest.class);
|
|
48 |
|
|
49 |
static UUID taxonUuid = UUID.fromString("ecb7a76e-694a-4706-b1ab-a2eb334173ff");
|
|
50 |
|
|
51 |
TaxonProfilePage p = null;
|
|
52 |
|
|
53 |
@Before
|
|
54 |
public void setUp() throws MalformedURLException {
|
|
55 |
|
|
56 |
if(p != null && driver != null ){
|
|
57 |
logger.debug("TaxonProfilePage p:" + p.getPageURL() + ", driver is at " + driver.getCurrentUrl());
|
|
58 |
}
|
|
59 |
p = new TaxonProfilePage(driver, getContext(), taxonUuid);
|
|
60 |
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
@Test
|
|
65 |
public void testTitleAndTabs() {
|
|
66 |
|
|
67 |
assertEquals(getContext().prepareTitle("Lactuca triquetra"), p.getTitle());
|
|
68 |
assertNull("Authorship information should be hidden", p.getAuthorInformationText());
|
|
69 |
|
|
70 |
List<LinkElement> primaryTabs = p.getPrimaryTabs();
|
|
71 |
int tabId = 0;
|
|
72 |
assertEquals("General", primaryTabs.get(tabId++).getText());
|
|
73 |
assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
|
|
74 |
assertEquals("Images", primaryTabs.get(tabId++).getText());
|
|
75 |
assertEquals("Specimens", primaryTabs.get(tabId++).getText());
|
|
76 |
assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
|
|
77 |
|
|
78 |
}
|
|
79 |
|
|
80 |
@Test
|
|
81 |
public void testProfileImage() {
|
|
82 |
ImgElement profileImage = p.getProfileImage();
|
|
83 |
assertNotNull("Expecting profile images to be switched on", profileImage);
|
|
84 |
assertTrue("Expecting image Lactuca_triquetra_Bc_01.JPG", profileImage.getSrcUrl().toString().endsWith("/Lactuca_triquetra_Bc_01.JPG"));
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
@Test
|
|
89 |
public void testFeatures() {
|
|
90 |
assertEquals("Content", p.getTableOfContentHeader());
|
|
91 |
List<LinkElement> links = p.getTableOfContentLinks();
|
|
92 |
assertNotNull("Expecting a list of TOC links in the profile page.", links);
|
|
93 |
|
|
94 |
FeatureBlock featureBlock;
|
|
95 |
int featureId = 0;
|
|
96 |
|
|
97 |
int descriptionElementFontSize = 12;
|
|
98 |
String expectedCssDisplay = "inline";
|
|
99 |
String expectedListStyleType = "none";
|
|
100 |
String expectedListStylePosition = "outside";
|
|
101 |
String expectedListStyleImage = "none";
|
|
102 |
int indent = 0;
|
|
103 |
|
|
104 |
/* Description */
|
|
105 |
String featureClass = "description";
|
|
106 |
String featureLabel = "Description";
|
|
107 |
String blockTextFull = null;
|
|
108 |
String blockTextBegin = featureLabel + "\nHerb, perennial, scoparious, 40-80 cm high. Flowering stems erect, triangular, medullary, glaucous-green, soon leafless, strongly branched; branches erect, slender. Cauline leaves few, glabrous.";
|
|
109 |
String blockTextEnd = "Pappus white, 6.0-7.0 mm long, persistent, fragile, shortly barbellate or scabridulous.\n\nbased on: Meikle, R.D. 1985: Flora auf Cyprus 2. - Kew (as Prenanthes triquetra).";
|
|
110 |
expectedListStyleType = "none";
|
|
111 |
|
|
112 |
p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
|
|
113 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
|
114 |
|
|
115 |
assertTrue(featureBlock.getText().startsWith(blockTextBegin));
|
|
116 |
assertTrue(featureBlock.getText().endsWith(blockTextEnd));
|
|
117 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
118 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
119 |
|
|
120 |
/* Distribution */
|
|
121 |
expectedCssDisplay = "block";
|
|
122 |
featureClass = "distribution";
|
|
123 |
featureLabel = "Distribution";
|
|
124 |
blockTextFull = featureLabel + "\n\n\n\nAsia-Temperate:\nCyprus 1,2; Lebanon-Syria (Lebanon 3,4,5); Palestine (Israel 5,6).\n1. Meikle, R. D., Flora of Cyprus 2. 1985, 2. Osorio-Tafall, B. H. & Serafim, G. M., List of the vascular plants of Cyprus. 1973, 3. Mouterde, P., Nouvelle flore du Liban et de la Syrie. Texte 3. 1978-1984, 4. Boissier, E., Flora Orientalis 3. 1875, 5. Post, G. E. , Flora of Syria, Palestine, and Sinai 2. 19336. (N)";
|
|
125 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
126 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
|
|
127 |
|
|
128 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
129 |
|
|
130 |
MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElements().get(0);
|
|
131 |
logger.info(descriptionElement.getText());
|
|
132 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
133 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
134 |
assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size());
|
|
135 |
assertEquals("Expecting 6 Footnotes", 6, featureBlock.getFootNotes().size());
|
|
136 |
|
|
137 |
assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
|
|
138 |
WebElement mapCaptionElement = null;
|
|
139 |
try {
|
|
140 |
mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
|
|
141 |
} catch (NoSuchElementException e){
|
|
142 |
/* IGNORE */
|
|
143 |
}
|
|
144 |
assertNull(mapCaptionElement);
|
|
145 |
|
|
146 |
/* Uses */
|
|
147 |
featureClass = "ecology";
|
|
148 |
featureLabel = "Ecology";
|
|
149 |
blockTextFull = featureLabel + "\n500 m. On chalky cliffs or in flushes on serpentine.\n\nfrom: Meikle, R. D. 1985: Flora of Cyprus 2. – Kew. (as Prenanthes triquetra)";
|
|
150 |
expectedCssDisplay = "inline";
|
|
151 |
|
|
152 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
153 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
|
154 |
|
|
155 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
156 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
157 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
158 |
assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
|
|
159 |
assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
|
|
160 |
|
|
161 |
|
|
162 |
/* Common names */
|
|
163 |
featureClass = "common_names";
|
|
164 |
featureLabel = "Common names";
|
|
165 |
expectedCssDisplay = "block";
|
|
166 |
blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكان7\n7. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000";
|
|
167 |
|
|
168 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
169 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "li");
|
|
170 |
|
|
171 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
172 |
|
|
173 |
|
|
174 |
/* Uses */
|
|
175 |
featureClass = "credits";
|
|
176 |
featureLabel = "Credits";
|
|
177 |
blockTextFull = featureLabel + "\nChristodoulou C. S. 2009: Images (1 added).\nMakris C. 2009: Images (1 added).";
|
|
178 |
expectedCssDisplay = "block";
|
|
179 |
|
|
180 |
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
|
181 |
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
|
182 |
|
|
183 |
assertEquals(blockTextFull, featureBlock.getText());
|
|
184 |
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
|
185 |
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
|
186 |
assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
|
|
187 |
assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
|
|
188 |
|
|
189 |
}
|
|
190 | 190 |
|
191 | 191 |
} |
5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Cyprus_HybridTest.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.dataportal.selenium.tests.cyprus; |
11 | 11 |
|
12 | 12 |
import static org.junit.Assert.assertEquals; |
13 |
import static org.junit.Assert.assertTrue; |
|
13 | 14 |
|
14 | 15 |
import java.net.MalformedURLException; |
15 | 16 |
import java.util.UUID; |
16 | 17 |
|
17 |
import org.junit.Ignore; |
|
18 | 18 |
import org.junit.Test; |
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.dataportal.DataPortalContext; |
21 |
import eu.etaxonomy.dataportal.elements.ClassificationTreeBlock; |
|
22 |
import eu.etaxonomy.dataportal.elements.ClassificationTreeElement; |
|
21 | 23 |
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase; |
22 | 24 |
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts; |
25 |
import eu.etaxonomy.dataportal.pages.TaxonProfilePage; |
|
23 | 26 |
import eu.etaxonomy.dataportal.pages.TaxonSynonymyPage; |
24 | 27 |
|
25 | 28 |
/** |
... | ... | |
32 | 35 |
public class Cyprus_HybridTest extends CdmDataPortalTestBase{ |
33 | 36 |
|
34 | 37 |
|
35 |
static UUID orchiserapias_Uuid = UUID.fromString("0aee7eea-84e7-4b61-8cb6-d17313cc9b80");
|
|
38 |
static UUID orchiserapias_Uuid = UUID.fromString("0aee7eea-84e7-4b61-8cb6-d17313cc9b80");
|
|
36 | 39 |
|
37 |
static UUID epilobium_aschersonianum_Uuid = UUID.fromString("e13ea422-5d45-477b-ade3-8dc84dbc9dbc");
|
|
40 |
static UUID epilobium_aschersonianum_Uuid = UUID.fromString("e13ea422-5d45-477b-ade3-8dc84dbc9dbc");
|
|
38 | 41 |
|
42 |
// |
|
43 |
static UUID aegilops_biuncialis_x_geniculata_Uuid = UUID.fromString("88ff0fbb-c0df-46c1-9969-cf318ea97dbb"); |
|
39 | 44 |
|
40 |
@Test |
|
41 |
public void orchiserapias() throws MalformedURLException { |
|
42 |
TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), orchiserapias_Uuid); |
|
43 |
String expectedName = "×Orchiserapias"; |
|
44 |
assertEquals(getContext().prepareTitle(expectedName), p.getTitle()); |
|
45 |
assertEquals(expectedName, p.getAcceptedName()); |
|
46 |
assertEquals("≡ Orchis × Serapias", p.getHomotypicalGroupSynonymName(1)); |
|
47 |
} |
|
48 | 45 |
|
49 |
@Test |
|
50 |
public void epilobium_aschersonianum() throws MalformedURLException { |
|
51 |
TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), epilobium_aschersonianum_Uuid); |
|
52 |
assertEquals(getContext().prepareTitle("Epilobium ×aschersonianum"), p.getTitle()); |
|
53 |
assertEquals("Epilobium ×aschersonianum Hausskn.", p.getAcceptedName()); |
|
54 |
assertEquals("≡ Epilobium lanceolatum × parviflorum", p.getHomotypicalGroupSynonymName(1)); |
|
55 |
} |
|
46 |
@Test |
|
47 |
public void orchiserapias() throws MalformedURLException { |
|
48 |
TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), orchiserapias_Uuid); |
|
49 |
String expectedName = "×Orchiserapias"; |
|
50 |
assertEquals(getContext().prepareTitle(expectedName), p.getTitle()); |
|
51 |
assertEquals(expectedName, p.getAcceptedName()); |
|
52 |
assertEquals("≡ Orchis × Serapias", p.getHomotypicalGroupSynonymName(1)); |
|
53 |
} |
|
56 | 54 |
|
55 |
@Test |
|
56 |
public void epilobium_aschersonianum() throws MalformedURLException { |
|
57 |
TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), epilobium_aschersonianum_Uuid); |
|
58 |
assertEquals(getContext().prepareTitle("Epilobium ×aschersonianum"), p.getTitle()); |
|
59 |
assertEquals("Epilobium ×aschersonianum Hausskn.", p.getAcceptedName()); |
|
60 |
assertEquals("≡ Epilobium lanceolatum × parviflorum", p.getHomotypicalGroupSynonymName(1)); |
|
61 |
} |
|
62 |
|
|
63 |
@Test |
|
64 |
public void aegilops_biuncialis_x_geniculata() throws MalformedURLException { |
|
65 |
TaxonProfilePage p = new TaxonProfilePage(driver, getContext(), aegilops_biuncialis_x_geniculata_Uuid); |
|
66 |
assertEquals(getContext().prepareTitle("Aegilops biuncialis × geniculata"), p.getTitle()); |
|
67 |
ClassificationTreeBlock classificationTree = p.getClassificationTree(); |
|
68 |
ClassificationTreeElement focusedElement = classificationTree.getFocusedElement(); |
|
69 |
assertTrue(classificationTree.isVisibleInViewPort(focusedElement)); |
|
70 |
assertEquals("Abbreviated form of name should be used", "A. biuncialis × geniculata", focusedElement.getTaxonName()); |
|
71 |
} |
|
57 | 72 |
|
58 | 73 |
} |
Also available in: Unified diff
AT: committing Dataportal to Branch post Merge