Revision adfb51b3
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/BaseElement.java | ||
---|---|---|
17 | 17 |
import org.apache.log4j.Logger; |
18 | 18 |
import org.openqa.selenium.By; |
19 | 19 |
import org.openqa.selenium.NoSuchElementException; |
20 |
import org.openqa.selenium.WebDriver; |
|
21 |
import org.openqa.selenium.WebDriverException; |
|
20 | 22 |
import org.openqa.selenium.WebElement; |
23 |
import org.openqa.selenium.support.ui.ExpectedCondition; |
|
24 |
import org.openqa.selenium.support.ui.WebDriverWait; |
|
21 | 25 |
|
22 | 26 |
/** |
23 | 27 |
* @author Andreas Kohlbecker |
... | ... | |
38 | 42 |
|
39 | 43 |
private List<LinkElement> linksInElement = null; |
40 | 44 |
|
45 |
List<String> linkTargets = null; |
|
46 |
|
|
41 | 47 |
private String text = null; |
42 | 48 |
|
43 | 49 |
|
... | ... | |
88 | 94 |
return linksInElement; |
89 | 95 |
} |
90 | 96 |
|
91 |
public List<String> getLinkTargets(){ |
|
92 |
|
|
93 |
List<String> targets = new ArrayList<String>(); |
|
97 |
/** |
|
98 |
* |
|
99 |
* @param driver the currently used WebDriver instance |
|
100 |
* @return |
|
101 |
*/ |
|
102 |
public List<String> getLinkTargets(WebDriver driver){ |
|
94 | 103 |
|
95 |
if(getElement().getTagName().equals("a") && getElement().getAttribute("target") != null && getElement().getAttribute("target").length() > 0){ |
|
96 |
targets.add(getElement().getAttribute("target")); |
|
97 |
} else { |
|
98 |
try { |
|
99 |
targets.add(getElement().findElement(By.xpath("./a[@target]")).getAttribute("target")); |
|
100 |
} catch (NoSuchElementException e) { |
|
101 |
logger.debug("No target window found"); |
|
102 |
/* IGNORE */ |
|
104 |
if(linkTargets == null){ |
|
105 |
linkTargets = new ArrayList<String>(); |
|
106 |
if(getElement().getTagName().equals("a") && getElement().getAttribute("target") != null && getElement().getAttribute("target").length() > 0){ |
|
107 |
linkTargets.add(getElement().getAttribute("target")); |
|
108 |
} else { |
|
109 |
try { |
|
110 |
WebDriverWait wait = new WebDriverWait(driver, 5); |
|
111 |
|
|
112 |
List<WebElement> anchorTags = wait.until(new ExpectedCondition<List<WebElement>>(){ |
|
113 |
@Override |
|
114 |
public List<WebElement> apply(WebDriver d) { |
|
115 |
return d.findElements(By.tagName("a")); |
|
116 |
} |
|
117 |
} |
|
118 |
); |
|
119 |
|
|
120 |
WebElement linkWithTarget = null; |
|
121 |
if(anchorTags.size() > 0){ |
|
122 |
if(anchorTags.get(0).getAttribute("target") != null) { |
|
123 |
linkWithTarget = anchorTags.get(0); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
if(linkWithTarget != null){ // assuming that there is only one |
|
128 |
linkTargets.add(linkWithTarget.getAttribute("target")); |
|
129 |
} |
|
130 |
} catch (NoSuchElementException e) { |
|
131 |
logger.debug("No target window found"); |
|
132 |
/* IGNORE */ |
|
133 |
} catch (WebDriverException e) { |
|
134 |
logger.debug("timed out", e); |
|
135 |
/* IGNORE */ |
|
136 |
} |
|
103 | 137 |
} |
104 | 138 |
} |
105 |
return targets;
|
|
139 |
return linkTargets;
|
|
106 | 140 |
} |
107 | 141 |
|
108 | 142 |
/** |
... | ... | |
125 | 159 |
/** |
126 | 160 |
* @return |
127 | 161 |
*/ |
128 |
public String toSting() { |
|
162 |
@Override |
|
163 |
public String toString() { |
|
129 | 164 |
return this.getClass().getSimpleName() + "<" + this.getElement().getTagName() + ">" ; |
130 | 165 |
} |
131 | 166 |
|
... | ... | |
150 | 185 |
if(textSnipped.length() > 50){ |
151 | 186 |
textSnipped = textSnipped.substring(0, 50) + "..."; |
152 | 187 |
} |
153 |
List<String> targets = getLinkTargets(); |
|
154 |
return "<" + getElement().getTagName() + " class=\""+ getElement().getAttribute("class")+ "\"/>" + textSnipped + " ;Links:" + links + (targets.isEmpty()? "" : ", LinkTargets: '" + StringUtils.join(targets, ", ") + "'"); |
|
188 |
String targets = "LinkTargets UN-INITIALIZED"; |
|
189 |
if(linkTargets != null) { |
|
190 |
targets = linkTargets.isEmpty()? "" : ", LinkTargets: '" + StringUtils.join(linkTargets.toArray(), ", ") + "'"; |
|
191 |
} |
|
192 |
return "<" + getElement().getTagName() + " class=\""+ getElement().getAttribute("class")+ "\"/>" + textSnipped + " ;Links:" + links + targets; |
|
155 | 193 |
} |
156 | 194 |
|
157 |
|
|
158 | 195 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/LinkElement.java | ||
---|---|---|
22 | 22 |
public class LinkElement extends BaseElement { |
23 | 23 |
|
24 | 24 |
private String href = null; |
25 |
|
|
25 | 26 |
public String getUrl() { |
26 | 27 |
return href; |
27 | 28 |
} |
... | ... | |
47 | 48 |
} |
48 | 49 |
|
49 | 50 |
@Override |
50 |
public String toSting(){ |
|
51 |
return super.toSting() + ": " + getUrl() + "";
|
|
51 |
public String toString(){
|
|
52 |
return super.toString() + ": " + (getUrl() != null ? getUrl() : "NO URL") + "";
|
|
52 | 53 |
} |
53 | 54 |
|
54 | 55 |
public static boolean testIfLinkElement(BaseElement element, String text, String href) { |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/MultipartDescriptionElementRepresentation.java | ||
---|---|---|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
@Override |
71 |
public String toSting() { |
|
71 |
public String toString() {
|
|
72 | 72 |
StringBuilder toStringRepresentatin = new StringBuilder(this.getClass().getSimpleName()); |
73 | 73 |
for (DescriptionElementRepresentation element : multipartElements) { |
74 | 74 |
toStringRepresentatin.append("<" + element.getElement().getTagName() + ">"); |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/TaxonListElement.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.dataportal.elements; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import javax.swing.Box.Filler; |
|
16 |
|
|
17 | 12 |
import org.openqa.selenium.By; |
18 | 13 |
import org.openqa.selenium.WebElement; |
19 | 14 |
|
20 |
import eu.etaxonomy.dataportal.pages.GenericPortalPage; |
|
21 |
import eu.etaxonomy.dataportal.pages.PortalPage; |
|
22 |
import eu.etaxonomy.dataportal.pages.TaxonProfilePage; |
|
23 |
import eu.etaxonomy.dataportal.pages.TaxonSearchResultPage; |
|
24 |
import eu.etaxonomy.dataportal.selenium.AllTrue; |
|
25 |
import eu.etaxonomy.dataportal.selenium.JUnitWebDriverWait; |
|
26 |
import eu.etaxonomy.dataportal.selenium.PageTitleValidated; |
|
27 |
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated; |
|
28 |
|
|
29 | 15 |
/** |
30 | 16 |
* @author andreas |
31 | 17 |
* @date Aug 29, 2011 |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java | ||
---|---|---|
8 | 8 |
import java.util.concurrent.TimeUnit; |
9 | 9 |
|
10 | 10 |
import org.apache.bcel.verifier.exc.LinkingConstraintException; |
11 |
import org.apache.commons.lang.StringUtils; |
|
12 | 11 |
import org.apache.log4j.Logger; |
13 | 12 |
import org.openqa.selenium.By; |
14 | 13 |
import org.openqa.selenium.NoSuchElementException; |
... | ... | |
334 | 333 |
public <T extends PortalPage> T clickLink(BaseElement element, Function<? super WebDriver, Boolean> isTrue, Class<T> type, Long duration, TimeUnit waitUnit) { |
335 | 334 |
|
336 | 335 |
String targetWindow = null; |
337 |
List<String> targets = element.getLinkTargets(); |
|
336 |
List<String> targets = element.getLinkTargets(driver);
|
|
338 | 337 |
if(targets.size() > 0){ |
339 | 338 |
targetWindow = targets.get(0); |
340 | 339 |
} |
341 | 340 |
|
342 |
if(logger.isInfoEnabled()){ |
|
343 |
logger.info("clicking on " + element.toStringWithLinks());
|
|
341 |
if(logger.isInfoEnabled() || logger.isDebugEnabled()){
|
|
342 |
logger.info("clickLink() on " + element.toStringWithLinks());
|
|
344 | 343 |
} |
345 | 344 |
element.getElement().click(); |
346 | 345 |
if(targetWindow != null){ |
... | ... | |
386 | 385 |
} |
387 | 386 |
|
388 | 387 |
|
389 |
/**
|
|
390 |
* replaces all underscores '_' by hyphens '-'
|
|
391 |
*
|
|
392 |
* @param featureName
|
|
393 |
* @return
|
|
394 |
*/
|
|
395 |
protected String normalizeClassAttribute(String featureName) {
|
|
396 |
return featureName.replace('_', '-');
|
|
397 |
}
|
|
388 |
/**
|
|
389 |
* replaces all underscores '_' by hyphens '-'
|
|
390 |
*
|
|
391 |
* @param featureName
|
|
392 |
* @return
|
|
393 |
*/
|
|
394 |
protected String normalizeClassAttribute(String featureName) {
|
|
395 |
return featureName.replace('_', '-');
|
|
396 |
}
|
|
398 | 397 |
|
399 | 398 |
|
400 | 399 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSearchResultPage.java | ||
---|---|---|
35 | 35 |
*/ |
36 | 36 |
public class TaxonSearchResultPage extends GenericPortalPage { |
37 | 37 |
|
38 |
public static final Logger logger = Logger.getLogger(TaxonSearchResultPage.class); |
|
39 |
|
|
40 |
private static String drupalPagePathBase = "cdm_dataportal/search/taxon"; |
|
41 |
|
|
42 |
@FindBy(id="search_results") |
|
43 |
@CacheLookup |
|
44 |
private WebElement searchResults; |
|
45 |
|
|
46 |
//class=page_options |
|
47 |
@FindBy(className="page_options") |
|
48 |
@CacheLookup |
|
49 |
private WebElement pageOptions; |
|
50 |
|
|
51 |
//class=pager |
|
52 |
@FindBy(className="pager") |
|
53 |
@CacheLookup |
|
54 |
private WebElement pager; |
|
55 |
|
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase() |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
protected String getDrupalPageBase() { |
|
62 |
return drupalPagePathBase; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* @param driver |
|
67 |
* @param context |
|
68 |
* @throws Exception |
|
69 |
*/ |
|
70 |
public TaxonSearchResultPage(WebDriver driver, DataPortalContext context) throws Exception { |
|
71 |
super(driver, context); |
|
72 |
} |
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* Find and return the result n-th item of the result list. |
|
77 |
* The item can be specified by the index paramter. |
|
78 |
* @param index 1-based index to identify the resultset item. |
|
79 |
* This index will be used in a xpath query. |
|
80 |
* @return |
|
81 |
*/ |
|
82 |
public TaxonListElement getResultItem(int index) { |
|
83 |
|
|
84 |
TaxonListElement entry = new TaxonListElement(searchResults.findElement(By.xpath("ul/li[" + index + "]"))); |
|
85 |
|
|
86 |
return entry; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Find and returns all items of the result list. |
|
91 |
* @return |
|
92 |
*/ |
|
93 |
public List<TaxonListElement> getResultItems() { |
|
94 |
|
|
95 |
List<WebElement> entryList = searchResults.findElements(By.xpath("/ul/li")); |
|
96 |
List<TaxonListElement> taxonListElements = new ArrayList<TaxonListElement>(); |
|
97 |
for(WebElement entry : entryList){ |
|
98 |
taxonListElements.add(new TaxonListElement(entry)); |
|
99 |
} |
|
100 |
return taxonListElements; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* @throws Exception |
|
105 |
* |
|
106 |
*/ |
|
107 |
@SuppressWarnings("unchecked") |
|
108 |
public <T extends PortalPage> T clickTaxonName(TaxonListElement taxonListElement) throws Exception { |
|
109 |
|
|
110 |
LinkElement taxonlink = new LinkElement(taxonListElement.getElement().findElement(By.tagName("a"))); |
|
111 |
return (T) clickLink(taxonlink, new VisibilityOfElementLocated(By.id("featureTOC")), TaxonProfilePage.class, 2l, TimeUnit.MINUTES); |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* @return a two dimensional array representing the media items in the gallery, or null if no gallery exists. |
|
117 |
*/ |
|
118 |
public List<List<GalleryImage>> getGalleryImagesOf(TaxonListElement taxonListElement) { |
|
119 |
|
|
120 |
|
|
121 |
WebElement gallery = taxonListElement.getElement().findElement(By.className("media_gallery")); |
|
122 |
|
|
123 |
if( gallery == null){ |
|
124 |
return null; |
|
125 |
} |
|
126 |
|
|
127 |
ArrayList<List<GalleryImage>> galleryImageRows = new ArrayList<List<GalleryImage>>(); |
|
128 |
|
|
129 |
List<WebElement> tableRows = gallery.findElements(By.tagName("tr")); |
|
130 |
logger.debug("GalleryImages - total rows " + tableRows.size()); |
|
131 |
// loop table rows |
|
132 |
for(int rowId = 0; rowId * 2 < tableRows.size() && tableRows.size() > 0; rowId++ ){ |
|
133 |
logger.debug("GalleryImages - gallery row " + rowId ); |
|
134 |
List<WebElement> imageCells = tableRows.get(rowId * 2).findElements(By.tagName("td")); |
|
135 |
logger.debug("GalleryImages - number of image cells: " + imageCells.size()); |
|
136 |
List<WebElement> captionCells = null; |
|
137 |
if(tableRows.size() > rowId * 2 + 1){ |
|
138 |
captionCells = tableRows.get(rowId * 2 + 1).findElements(By.tagName("td")); |
|
139 |
logger.debug("GalleryImages - number of caption cells: " + captionCells.size()); |
|
140 |
} |
|
141 |
|
|
142 |
galleryImageRows.add(new ArrayList<GalleryImage>()); |
|
143 |
|
|
144 |
// loop table cells in row |
|
145 |
for(int cellId = 0; cellId < imageCells.size(); cellId++) { |
|
146 |
logger.debug("cellId:" + cellId); |
|
147 |
WebElement imageCell = imageCells.get(cellId); |
|
148 |
WebElement captionCell = null; |
|
149 |
if(captionCells != null && captionCells.size() > cellId){ |
|
150 |
captionCell = captionCells.get(cellId); |
|
151 |
wait.until(new AllTrue( |
|
152 |
new ChildElementVisible(imageCell, By.tagName("img")), |
|
153 |
new ChildElementVisible(captionCell, By.tagName("dl")) |
|
154 |
)); |
|
155 |
|
|
156 |
} else { |
|
157 |
wait.until(new ChildElementVisible(imageCell, By.tagName("img"))); |
|
158 |
} |
|
159 |
galleryImageRows.get(rowId).add(new GalleryImage(imageCell, captionCell)); |
|
160 |
} |
|
161 |
|
|
162 |
} |
|
163 |
|
|
164 |
return galleryImageRows; |
|
165 |
} |
|
38 |
public static final Logger logger = Logger.getLogger(TaxonSearchResultPage.class); |
|
39 |
|
|
40 |
private static String drupalPagePathBase = "cdm_dataportal/search/taxon"; |
|
41 |
|
|
42 |
@FindBy(id="search_results") |
|
43 |
@CacheLookup |
|
44 |
private WebElement searchResults; |
|
45 |
|
|
46 |
//class=page_options |
|
47 |
@FindBy(className="page_options") |
|
48 |
@CacheLookup |
|
49 |
private WebElement pageOptions; |
|
50 |
|
|
51 |
//class=pager |
|
52 |
@FindBy(className="pager") |
|
53 |
@CacheLookup |
|
54 |
private WebElement pager; |
|
55 |
|
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase() |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
protected String getDrupalPageBase() { |
|
62 |
return drupalPagePathBase; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* @param driver |
|
67 |
* @param context |
|
68 |
* @throws Exception |
|
69 |
*/ |
|
70 |
public TaxonSearchResultPage(WebDriver driver, DataPortalContext context) throws Exception { |
|
71 |
super(driver, context); |
|
72 |
} |
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* Find and return the result n-th item of the result list. |
|
77 |
* The item can be specified by the index paramter. |
|
78 |
* @param index 1-based index to identify the resultset item. |
|
79 |
* This index will be used in a xpath query. |
|
80 |
* @return |
|
81 |
*/ |
|
82 |
public TaxonListElement getResultItem(int index) { |
|
83 |
|
|
84 |
TaxonListElement entry = new TaxonListElement(searchResults.findElement(By.xpath("ul/li[" + index + "]"))); |
|
85 |
|
|
86 |
return entry; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Find and returns all items of the result list. |
|
91 |
* @return |
|
92 |
*/ |
|
93 |
public List<TaxonListElement> getResultItems() { |
|
94 |
|
|
95 |
List<WebElement> entryList = searchResults.findElements(By.xpath("/ul/li")); |
|
96 |
List<TaxonListElement> taxonListElements = new ArrayList<TaxonListElement>(); |
|
97 |
for(WebElement entry : entryList){ |
|
98 |
taxonListElements.add(new TaxonListElement(entry)); |
|
99 |
} |
|
100 |
return taxonListElements; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* @throws Exception |
|
105 |
* |
|
106 |
*/ |
|
107 |
@SuppressWarnings("unchecked") |
|
108 |
public <T extends PortalPage> T clickTaxonName(TaxonListElement taxonListElement, Class<T> pageClass) throws Exception { |
|
109 |
|
|
110 |
LinkElement taxonlink = new LinkElement(taxonListElement.getElement().findElement(By.tagName("a"))); |
|
111 |
logger.debug("taxonlink to click: " + taxonlink.toString() + " [" + taxonlink.getElement().toString() + "]"); |
|
112 |
return (T) clickLink(taxonlink, new VisibilityOfElementLocated(By.id("featureTOC")), pageClass, 2l, TimeUnit.MINUTES); |
|
113 |
|
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* @return a two dimensional array representing the media items in the gallery, or null if no gallery exists. |
|
118 |
*/ |
|
119 |
public List<List<GalleryImage>> getGalleryImagesOf(TaxonListElement taxonListElement) { |
|
120 |
|
|
121 |
|
|
122 |
WebElement gallery = taxonListElement.getElement().findElement(By.className("media_gallery")); |
|
123 |
|
|
124 |
if( gallery == null){ |
|
125 |
return null; |
|
126 |
} |
|
127 |
|
|
128 |
ArrayList<List<GalleryImage>> galleryImageRows = new ArrayList<List<GalleryImage>>(); |
|
129 |
|
|
130 |
List<WebElement> tableRows = gallery.findElements(By.tagName("tr")); |
|
131 |
logger.debug("GalleryImages - total rows " + tableRows.size()); |
|
132 |
// loop table rows |
|
133 |
for(int rowId = 0; rowId * 2 < tableRows.size() && tableRows.size() > 0; rowId++ ){ |
|
134 |
logger.debug("GalleryImages - gallery row " + rowId ); |
|
135 |
List<WebElement> imageCells = tableRows.get(rowId * 2).findElements(By.tagName("td")); |
|
136 |
logger.debug("GalleryImages - number of image cells: " + imageCells.size()); |
|
137 |
List<WebElement> captionCells = null; |
|
138 |
if(tableRows.size() > rowId * 2 + 1){ |
|
139 |
captionCells = tableRows.get(rowId * 2 + 1).findElements(By.tagName("td")); |
|
140 |
logger.debug("GalleryImages - number of caption cells: " + captionCells.size()); |
|
141 |
} |
|
142 |
|
|
143 |
galleryImageRows.add(new ArrayList<GalleryImage>()); |
|
144 |
|
|
145 |
// loop table cells in row |
|
146 |
for(int cellId = 0; cellId < imageCells.size(); cellId++) { |
|
147 |
logger.debug("cellId:" + cellId); |
|
148 |
WebElement imageCell = imageCells.get(cellId); |
|
149 |
WebElement captionCell = null; |
|
150 |
if(captionCells != null && captionCells.size() > cellId){ |
|
151 |
captionCell = captionCells.get(cellId); |
|
152 |
wait.until(new AllTrue( |
|
153 |
new ChildElementVisible(imageCell, By.tagName("img")), |
|
154 |
new ChildElementVisible(captionCell, By.tagName("dl")) |
|
155 |
)); |
|
156 |
|
|
157 |
} else { |
|
158 |
wait.until(new ChildElementVisible(imageCell, By.tagName("img"))); |
|
159 |
} |
|
160 |
galleryImageRows.get(rowId).add(new GalleryImage(imageCell, captionCell)); |
|
161 |
} |
|
162 |
|
|
163 |
} |
|
164 |
|
|
165 |
return galleryImageRows; |
|
166 |
} |
|
166 | 167 |
|
167 | 168 |
|
168 | 169 |
|
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/JUnitWebDriverWait.java | ||
---|---|---|
13 | 13 |
public class JUnitWebDriverWait extends WebDriverWait { |
14 | 14 |
|
15 | 15 |
|
16 |
/**
|
|
17 |
* @param driver
|
|
18 |
* @param timeOutInSeconds
|
|
19 |
*/
|
|
20 |
public JUnitWebDriverWait(WebDriver driver, long timeOutInSeconds) {
|
|
21 |
super(driver, timeOutInSeconds);
|
|
22 |
}
|
|
16 |
/**
|
|
17 |
* @param driver
|
|
18 |
* @param timeOutInSeconds
|
|
19 |
*/
|
|
20 |
public JUnitWebDriverWait(WebDriver driver, long timeOutInSeconds) {
|
|
21 |
super(driver, timeOutInSeconds);
|
|
22 |
}
|
|
23 | 23 |
|
24 |
@Override
|
|
25 |
protected RuntimeException timeoutException(String message, RuntimeException lastException) {
|
|
26 |
throw new AssertionError(message);
|
|
27 |
}
|
|
24 |
@Override
|
|
25 |
protected RuntimeException timeoutException(String message, Throwable lastException) {
|
|
26 |
throw new AssertionError(message);
|
|
27 |
}
|
|
28 | 28 |
|
29 | 29 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/WebDriverFactory.java | ||
---|---|---|
4 | 4 |
package eu.etaxonomy.dataportal.selenium; |
5 | 5 |
|
6 | 6 |
import java.io.IOException; |
7 |
import java.util.concurrent.TimeUnit; |
|
7 | 8 |
|
8 | 9 |
import org.apache.log4j.Logger; |
9 | 10 |
import org.openqa.selenium.WebDriver; |
... | ... | |
33 | 34 |
private static final String FIREXPATH_VERSION = "0.9.7"; |
34 | 35 |
private static final String DISABLE_ADD_ON_COMPATIBILITY_CHECKS_VERSION = "1.3"; |
35 | 36 |
|
37 |
private static final long IMPLICIT_WAIT_DEFAULT = 5; |
|
38 |
|
|
39 |
|
|
36 | 40 |
public static WebDriver newWebDriver() { |
37 | 41 |
|
38 | 42 |
WebDriver newDriver = null; |
... | ... | |
51 | 55 |
newDriver = initInternetExplorerDriver(); |
52 | 56 |
break; |
53 | 57 |
} |
58 |
|
|
54 | 59 |
} catch (NullPointerException e) { |
55 | 60 |
SystemUtils.handleInvalidSystemProperty(SYSTEM_PROPERTY_NAME_BROWSER, e); |
56 | 61 |
} catch (IllegalArgumentException e) { |
57 | 62 |
SystemUtils.handleInvalidSystemProperty(SYSTEM_PROPERTY_NAME_BROWSER, e); |
58 | 63 |
} |
64 |
|
|
65 |
newDriver.manage().timeouts().implicitlyWait(IMPLICIT_WAIT_DEFAULT, TimeUnit.SECONDS); |
|
66 |
logger.info("Implicit wait set to : " + IMPLICIT_WAIT_DEFAULT + TimeUnit.SECONDS); |
|
67 |
|
|
59 | 68 |
return newDriver; |
60 | 69 |
} |
61 | 70 |
|
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/CichorieaeSearchTest.java | ||
---|---|---|
35 | 35 |
@DataPortalContexts( { DataPortalContext.cichorieae }) |
36 | 36 |
public class CichorieaeSearchTest extends CdmDataPortalTestBase { |
37 | 37 |
|
38 |
private static GenericPortalPage homePage = null;
|
|
38 |
private static GenericPortalPage homePage = null;
|
|
39 | 39 |
|
40 |
@Before
|
|
41 |
public void setUp() throws Exception {
|
|
40 |
@Before
|
|
41 |
public void setUp() throws Exception {
|
|
42 | 42 |
|
43 |
driver.get(getContext().getBaseUri().toString());
|
|
44 |
homePage = new GenericPortalPage(driver, getContext());
|
|
43 |
driver.get(getContext().getBaseUri().toString());
|
|
44 |
homePage = new GenericPortalPage(driver, getContext());
|
|
45 | 45 |
|
46 |
}
|
|
46 |
}
|
|
47 | 47 |
|
48 |
@Test
|
|
49 |
public void testSearchLCommunis() throws Exception {
|
|
48 |
@Test
|
|
49 |
public void testSearchLCommunis() throws Exception {
|
|
50 | 50 |
|
51 |
TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
|
|
51 |
TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
|
|
52 | 52 |
|
53 |
assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
|
|
53 |
assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
|
|
54 | 54 |
|
55 |
TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
|
|
55 |
TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
|
|
56 | 56 |
|
57 |
assertEquals("Lapsana communis L., Sp. Pl.: 811. 1753", lapsanaCommunnis.getFullTaxonName());
|
|
57 |
assertEquals("Lapsana communis L., Sp. Pl.: 811. 1753", lapsanaCommunnis.getFullTaxonName());
|
|
58 | 58 |
|
59 |
WebElement nameElement = lapsanaCommunnis.getElement().findElement(By.className("BotanicalName"));
|
|
59 |
WebElement nameElement = lapsanaCommunnis.getElement().findElement(By.className("BotanicalName"));
|
|
60 | 60 |
|
61 |
WebElement namePart1 = nameElement.findElement(By.xpath("span[1]"));
|
|
62 |
Assert.assertEquals("Lapsana", namePart1.getText());
|
|
63 |
Assert.assertEquals("italic", namePart1.getCssValue("font-style"));
|
|
61 |
WebElement namePart1 = nameElement.findElement(By.xpath("span[1]"));
|
|
62 |
Assert.assertEquals("Lapsana", namePart1.getText());
|
|
63 |
Assert.assertEquals("italic", namePart1.getCssValue("font-style"));
|
|
64 | 64 |
|
65 |
WebElement namePart2 = nameElement.findElement(By.xpath("span[2]"));
|
|
66 |
Assert.assertEquals("communis", namePart2.getText());
|
|
67 |
Assert.assertEquals("italic", namePart2.getCssValue("font-style"));
|
|
65 |
WebElement namePart2 = nameElement.findElement(By.xpath("span[2]"));
|
|
66 |
Assert.assertEquals("communis", namePart2.getText());
|
|
67 |
Assert.assertEquals("italic", namePart2.getCssValue("font-style"));
|
|
68 | 68 |
|
69 |
WebElement authorPart = nameElement.findElement(By.xpath("span[3]"));
|
|
70 |
Assert.assertEquals("L.", authorPart.getText());
|
|
71 |
Assert.assertEquals("normal", authorPart.getCssValue("font-style"));
|
|
69 |
WebElement authorPart = nameElement.findElement(By.xpath("span[3]"));
|
|
70 |
Assert.assertEquals("L.", authorPart.getText());
|
|
71 |
Assert.assertEquals("normal", authorPart.getCssValue("font-style"));
|
|
72 | 72 |
|
73 |
WebElement referenceElement = lapsanaCommunnis.getElement().findElement(By.className("reference"));
|
|
74 |
Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
|
|
73 |
WebElement referenceElement = lapsanaCommunnis.getElement().findElement(By.className("reference"));
|
|
74 |
Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
|
|
75 | 75 |
|
76 |
PortalPage taxonProfilLapsanaCommunnis = searchResultPage.clickTaxonName(lapsanaCommunnis);
|
|
77 |
assertEquals(getContext().prepareTitle("Lapsana communis"), taxonProfilLapsanaCommunnis.getTitle());
|
|
78 |
}
|
|
76 |
PortalPage taxonProfilLapsanaCommunnis = searchResultPage.clickTaxonName(lapsanaCommunnis, PortalPage.class);
|
|
77 |
assertEquals(getContext().prepareTitle("Lapsana communis"), taxonProfilLapsanaCommunnis.getTitle());
|
|
78 |
}
|
|
79 | 79 |
|
80 |
@Test
|
|
81 |
public void testSearchLCommunis_ImageLinks() throws Exception {
|
|
80 |
@Test
|
|
81 |
public void testSearchLCommunis_ImageLinks() throws Exception {
|
|
82 | 82 |
|
83 |
TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
|
|
83 |
TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
|
|
84 | 84 |
|
85 |
assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
|
|
85 |
assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
|
|
86 | 86 |
|
87 |
TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
|
|
87 |
TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
|
|
88 | 88 |
|
89 |
List<List<GalleryImage>> galleryImageRows = searchResultPage.getGalleryImagesOf(lapsanaCommunnis);
|
|
89 |
List<List<GalleryImage>> galleryImageRows = searchResultPage.getGalleryImagesOf(lapsanaCommunnis);
|
|
90 | 90 |
|
91 |
assertEquals("Expecting one row of images", 1, galleryImageRows.size());
|
|
92 |
assertEquals("Expecting 4 images in row", 4, galleryImageRows.get(0).size());
|
|
91 |
assertEquals("Expecting one row of images", 1, galleryImageRows.size());
|
|
92 |
assertEquals("Expecting 4 images in row", 4, galleryImageRows.get(0).size());
|
|
93 | 93 |
|
94 |
GalleryImage firstImage = galleryImageRows.get(0).get(0);
|
|
95 |
assertNull("caption should be off", firstImage.getCaptionText());
|
|
96 |
searchResultPage.clickLink(firstImage.getImageLink(), new VisibilityOfElementLocated(By.id("images")), GenericPortalPage.class);
|
|
97 |
}
|
|
94 |
GalleryImage firstImage = galleryImageRows.get(0).get(0);
|
|
95 |
assertNull("caption should be off", firstImage.getCaptionText());
|
|
96 |
searchResultPage.clickLink(firstImage.getImageLink(), new VisibilityOfElementLocated(By.id("images")), GenericPortalPage.class);
|
|
97 |
}
|
|
98 | 98 |
|
99 | 99 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/flMalesiana/FloraMalesiana_OriginalSourceTest.java | ||
---|---|---|
15 | 15 |
import java.util.List; |
16 | 16 |
import java.util.UUID; |
17 | 17 |
|
18 |
import org.apache.log4j.Level; |
|
18 | 19 |
import org.junit.After; |
19 | 20 |
import org.junit.Before; |
20 | 21 |
import org.junit.Test; |
... | ... | |
43 | 44 |
@DataPortalContexts( { DataPortalContext.floramalesiana}) |
44 | 45 |
public class FloraMalesiana_OriginalSourceTest extends CdmDataPortalTestBase{ |
45 | 46 |
|
46 |
// Milichia speciosa |
|
47 |
static UUID taxonUuid = UUID.fromString("1f1f8356-a172-4f7d-ad98-e8a37489ce9f"); |
|
48 |
|
|
49 |
TaxonProfilePage p = null; |
|
50 |
|
|
51 |
private GenericPortalPage homePage; |
|
52 |
|
|
53 |
@Before |
|
54 |
public void setUp() throws Exception { |
|
55 |
|
|
56 |
driver.get(getContext().getBaseUri().toString()); |
|
57 |
homePage = new GenericPortalPage(driver, getContext()); |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
@After |
|
62 |
public void tearDown(){ |
|
63 |
logger.debug("@After"); |
|
64 |
} |
|
65 |
|
|
66 |
|
|
67 |
@Test |
|
68 |
public void Illicium() throws Exception { |
|
69 |
|
|
70 |
TaxonSearchResultPage searchResultPage = homePage.submitQuery("Illicium"); |
|
71 |
|
|
72 |
assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle()); |
|
73 |
|
|
74 |
TaxonListElement entryIillicium = searchResultPage.getResultItem(1); |
|
75 |
|
|
76 |
assertEquals("Illicium L. in Syst. Nat. ed. 10: 1050. 1759", entryIillicium.getFullTaxonName()); |
|
77 |
|
|
78 |
PortalPage taxonProfileIillicium = searchResultPage.clickTaxonName(entryIillicium); |
|
79 |
|
|
80 |
// assertNull("Authorship information should be hidden", p.getAuthorInformationText()); |
|
81 |
// |
|
82 |
// List<LinkElement> primaryTabs = p.getPrimaryTabs(); |
|
83 |
// assertEquals("Expecting 3 tabs", 3, primaryTabs.size()); |
|
84 |
// assertEquals("General", primaryTabs.get(0).getText()); |
|
85 |
// assertEquals("Nomenclature", primaryTabs.get(1).getText()); |
|
86 |
// assertEquals("Specimens", primaryTabs.get(2).getText()); |
|
87 |
// |
|
88 |
// assertEquals("Content", p.getTableOfContentHeader()); |
|
89 |
// List<LinkElement> tocLinks = p.getTableOfContentLinks(); |
|
90 |
// assertNotNull("Expecting a list of TOC links in the profile page.", tocLinks); |
|
91 |
// |
|
92 |
// p.testTableOfContentEntry(0, "Citations", "citation"); |
|
93 |
// p.testTableOfContentEntry(1, "Distribution", "distribution"); |
|
94 |
// p.testTableOfContentEntry(2, "Occurrence", "occurrence"); |
|
95 |
// |
|
96 |
// FeatureBlock featureBlock = p.getFeatureBlockAt(0, "citation", "ul", "li"); |
|
97 |
// assertEquals("expecting no footnote keys", 0, featureBlock.getFootNoteKeys().size()); |
|
98 |
// |
|
99 |
// List<WebElement> listElements = featureBlock.getElement().findElements(By.tagName("li")); |
|
100 |
// assertEquals("Expecting 48 listElements tags in \"Citations\"", 48, listElements.size()); |
|
101 |
// |
|
102 |
// // --- |
|
103 |
// assertEquals("Argyrites speciosa (Meigen, 1830): Croatia", listElements.get(0).getText()); |
|
104 |
// List<WebElement> anchorTags = listElements.get(0).findElements(By.tagName("a")); |
|
105 |
// assertEquals("Expecting one link", 1, anchorTags.size()); |
|
106 |
// assertTrue(anchorTags.get(0).getAttribute("href").endsWith("?q=cdm_dataportal/name/8d117f24-c9ba-44cd-bf9a-54f2b41e4a0f")); |
|
107 |
// |
|
108 |
// // --- |
|
109 |
// assertEquals("Milichia speciosa Meigen, 1830: type information (Becker 1902: 314)", listElements.get(2).getText()); |
|
110 |
// anchorTags = listElements.get(2).findElements(By.tagName("a")); |
|
111 |
// assertEquals("Expecting two links", 2, anchorTags.size()); |
|
112 |
// assertEquals("Milichia speciosa Meigen, 1830", anchorTags.get(0).getText()); |
|
113 |
// assertTrue(anchorTags.get(0).getAttribute("href").endsWith("?q=cdm_dataportal/name/031ab38f-54a7-4012-8595-31929a6f7f45")); |
|
114 |
// assertEquals("Becker 1902", anchorTags.get(1).getText()); |
|
115 |
// assertTrue(anchorTags.get(1).getAttribute("href").endsWith("?q=cdm_dataportal/reference/96d55a98-4811-4ad9-94d2-a306a212070b")); |
|
116 |
// |
|
117 |
// // --- |
|
118 |
// assertEquals("Milichia speciosa Meigen, 1830: checklist, Italy (Canzoneri & Gorodkov & Krivosheina & Munari & Nartshuk & Papp & Süss 1995: 25)", listElements.get(9).getText()); |
|
119 |
// anchorTags = listElements.get(9).findElements(By.tagName("a")); |
|
120 |
// assertEquals("Expecting two links", 2, anchorTags.size()); |
|
121 |
// assertEquals("Milichia speciosa Meigen, 1830", anchorTags.get(0).getText()); |
|
122 |
// assertTrue(anchorTags.get(0).getAttribute("href").endsWith("?q=cdm_dataportal/name/031ab38f-54a7-4012-8595-31929a6f7f45")); |
|
123 |
// assertEquals("Canzoneri & Gorodkov & Krivosheina & Munari & Nartshuk & Papp & Süss 1995", anchorTags.get(1).getText()); |
|
124 |
// assertTrue(anchorTags.get(1).getAttribute("href").endsWith("?q=cdm_dataportal/reference/338a6b6b-a26a-43e9-bf4a-6077b5a84668")); |
|
125 |
} |
|
47 |
private GenericPortalPage homePage; |
|
48 |
|
|
49 |
@Before |
|
50 |
public void setUp() throws Exception { |
|
51 |
|
|
52 |
driver.get(getContext().getBaseUri().toString()); |
|
53 |
homePage = new GenericPortalPage(driver, getContext()); |
|
54 |
} |
|
55 |
|
|
56 |
@After |
|
57 |
public void tearDown(){ |
|
58 |
logger.debug("@After"); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
@Test |
|
63 |
public void Illicium() throws Exception { |
|
64 |
|
|
65 |
TaxonSearchResultPage searchResultPage = homePage.submitQuery("Illicium"); |
|
66 |
|
|
67 |
assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle()); |
|
68 |
|
|
69 |
logger.debug("getting first result entry"); |
|
70 |
TaxonListElement entryIillicium = searchResultPage.getResultItem(1); |
|
71 |
|
|
72 |
logger.debug("checking FullTaxonName of first entry: " + entryIillicium.getElement().toString()); |
|
73 |
assertEquals("Illicium L. in Syst. Nat. ed. 10: 1050. 1759", entryIillicium.getFullTaxonName()); |
|
74 |
|
|
75 |
logger.debug("clicking TaxonName" + entryIillicium.getElement().toString()); |
|
76 |
TaxonProfilePage taxonProfileIillicium = searchResultPage.clickTaxonName(entryIillicium, TaxonProfilePage.class); |
|
77 |
|
|
78 |
// assertNull("Authorship information should be hidden", taxonProfileIillicium.getAuthorInformationText()); // FF WebDriver hangs here |
|
79 |
|
|
80 |
List<LinkElement> primaryTabs = taxonProfileIillicium.getPrimaryTabs(); |
|
81 |
assertEquals("Expecting 4 tabs", 4, primaryTabs.size()); |
|
82 |
assertEquals("General", primaryTabs.get(0).getText()); |
|
83 |
assertEquals("Synonymy", primaryTabs.get(1).getText()); |
|
84 |
assertEquals("Specimens", primaryTabs.get(2).getText()); |
|
85 |
assertEquals("Keys", primaryTabs.get(3).getText()); |
|
86 |
|
|
87 |
} |
|
126 | 88 |
|
127 | 89 |
} |
Also available in: Unified diff
fixing #2987 (selenium test Illicium@floramalesiana(eu.etaxonomy.dataportal.selenium.tests.flMalesiana.FloraMalesiana_OriginalSourceTest) fails due to timeouts) and adapting code to selenium 2.26.0 in pom