Revision 6325c7ad
Added by Andreas Kohlbecker almost 4 years ago
src/main/java/eu/etaxonomy/dataportal/elements/TypeDesignationElement.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
public TypeDesignationElement(WebElement element) { |
34 | 34 |
super(element); |
35 |
System.err.println(element.getTagName() + " | " + element.getText()); |
|
35 | 36 |
status = element.findElement(By.cssSelector(".type-status")); |
36 | 37 |
try { |
37 | 38 |
nameDescription = element.findElement(By.cssSelector(".description")); |
src/main/java/eu/etaxonomy/dataportal/pages/NamePage.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.dataportal.pages; |
|
10 |
|
|
11 |
import java.net.MalformedURLException; |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.Collections; |
|
14 |
import java.util.List; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import org.apache.log4j.Logger; |
|
18 |
import org.openqa.selenium.By; |
|
19 |
import org.openqa.selenium.WebDriver; |
|
20 |
import org.openqa.selenium.WebElement; |
|
21 |
import org.openqa.selenium.support.CacheLookup; |
|
22 |
import org.openqa.selenium.support.FindBy; |
|
23 |
|
|
24 |
import eu.etaxonomy.dataportal.DataPortalContext; |
|
25 |
import eu.etaxonomy.dataportal.elements.TypeDesignationElement; |
|
26 |
|
|
27 |
/** |
|
28 |
* @author a.kohlbecker |
|
29 |
* @since Feb 4, 2019 |
|
30 |
* |
|
31 |
*/ |
|
32 |
public class NamePage extends PortalPage { |
|
33 |
|
|
34 |
|
|
35 |
public static final Logger logger = Logger.getLogger(NamePage.class); |
|
36 |
|
|
37 |
protected static String drupalPagePathBase = "cdm_dataportal/name"; |
|
38 |
|
|
39 |
@FindBy(className = "typeDesignations") |
|
40 |
@CacheLookup |
|
41 |
private List<WebElement> typeDesignationContainers; |
|
42 |
|
|
43 |
private List<List<TypeDesignationElement>> typeDesignationElementsByContainer = null; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* @param driver |
|
48 |
* @param context |
|
49 |
* @throws Exception |
|
50 |
*/ |
|
51 |
public NamePage(WebDriver driver, DataPortalContext context) throws Exception { |
|
52 |
super(driver, context); |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
public NamePage(WebDriver driver, DataPortalContext context, UUID nameUuid) throws MalformedURLException { |
|
57 |
super(driver, context, nameUuid.toString()); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* {@inheritDoc} |
|
62 |
*/ |
|
63 |
@Override |
|
64 |
protected String getDrupalPageBase() { |
|
65 |
return drupalPagePathBase; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* @return the registrationItem |
|
70 |
*/ |
|
71 |
public List<TypeDesignationElement> getTypeDesignations(int typeDesignationsContainerIndex, String enclosingTag) { |
|
72 |
|
|
73 |
if(typeDesignationElementsByContainer == null){ |
|
74 |
typeDesignationElementsByContainer = new ArrayList<>(Collections.nCopies(typeDesignationContainers.size(), null)); |
|
75 |
} |
|
76 |
if(typeDesignationElementsByContainer.get(typeDesignationsContainerIndex) == null) { |
|
77 |
WebElement container = typeDesignationContainers.get(typeDesignationsContainerIndex); |
|
78 |
List<TypeDesignationElement> typeDesignationElements = new ArrayList<>(); |
|
79 |
List<WebElement> childrenElements = container.findElements(By.cssSelector(":scope > " + enclosingTag)); // direct children |
|
80 |
for(WebElement we : childrenElements) { |
|
81 |
typeDesignationElements.add(new TypeDesignationElement(we)); |
|
82 |
} |
|
83 |
typeDesignationElementsByContainer.add(typeDesignationsContainerIndex, typeDesignationElements); |
|
84 |
} |
|
85 |
return typeDesignationElementsByContainer.get(typeDesignationsContainerIndex); |
|
86 |
} |
|
87 |
|
|
88 |
} |
src/test/java/eu/etaxonomy/dataportal/selenium/tests/reference/TextualTypeDesignationTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2009 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.dataportal.selenium.tests.reference; |
|
10 |
|
|
11 |
import java.net.MalformedURLException; |
|
12 |
import java.util.List; |
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 |
import org.junit.Before; |
|
16 |
import org.junit.Test; |
|
17 |
import org.openqa.selenium.By; |
|
18 |
|
|
19 |
import eu.etaxonomy.dataportal.DataPortalSite; |
|
20 |
import eu.etaxonomy.dataportal.elements.TypeDesignationElement; |
|
21 |
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase; |
|
22 |
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts; |
|
23 |
import eu.etaxonomy.dataportal.pages.NamePage; |
|
24 |
|
|
25 |
/** |
|
26 |
* Issues to be covered by this TestClass: |
|
27 |
* |
|
28 |
* https://dev.e-taxonomy.eu/redmine/issues/8134 |
|
29 |
* |
|
30 |
* @author a.kohlbecker |
|
31 |
* |
|
32 |
*/ |
|
33 |
@DataPortalContexts( { DataPortalSite.reference }) |
|
34 |
public class TextualTypeDesignationTest extends CdmDataPortalTestBase{ |
|
35 |
|
|
36 |
static final UUID equisetum_arvense_n_uuid = UUID.fromString("ceebdc3f-f0ed-41df-bae1-6455316ca52a"); |
|
37 |
|
|
38 |
|
|
39 |
@Before |
|
40 |
public void setUp() throws Exception { |
|
41 |
driver.get(getContext().getBaseUri().toString()); |
|
42 |
} |
|
43 |
|
|
44 |
@Test |
|
45 |
public void testPageTitles() throws MalformedURLException { |
|
46 |
NamePage p = new NamePage(driver, getContext(), equisetum_arvense_n_uuid); |
|
47 |
assertEquals( |
|
48 |
"Equisetum arvense | Integration test reference", |
|
49 |
driver.getTitle() |
|
50 |
); |
|
51 |
assertEquals( |
|
52 |
"Equisetum arvense", |
|
53 |
driver.findElement(By.id("page-title")).getText() |
|
54 |
); |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
@Test |
|
59 |
public void testNamePage() throws MalformedURLException { |
|
60 |
NamePage p = new NamePage(driver, getContext(), equisetum_arvense_n_uuid); |
|
61 |
List<TypeDesignationElement> typeDesignations = p.getTypeDesignations(0, "div"); |
|
62 |
assertEquals("Type: Type specimen which may have beed assigned already: Jonsell & Jarvis, Nord. J. Bot. 14: 148 (1994)", typeDesignations.get(0).getText()); |
|
63 |
assertEquals("Type: \"LT: Clayton 341; (BM) LT designated by Jonsell & Jarvis, Nord. J. Bot. 14: 148 (1994)\"", typeDesignations.get(1).getText()); |
|
64 |
} |
|
65 |
|
|
66 |
} |
Also available in: Unified diff
ref #8134 test for TextualTypeDesignation (requires new page class: NamePage)