Project

General

Profile

« Previous | Next » 

Revision 3f140bb9

Added by Andreas Kohlbecker over 8 years ago

implemented selenium test for PolytomousKeys #4983

View differences:

7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/PolytomousKeyPage.java
1 1
package eu.etaxonomy.dataportal.pages;
2 2

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

  
......
12 12
import org.openqa.selenium.WebElement;
13 13
import org.openqa.selenium.support.CacheLookup;
14 14
import org.openqa.selenium.support.FindBy;
15
import org.openqa.selenium.support.PageFactory;
16 15

  
17 16
import eu.etaxonomy.dataportal.DataPortalContext;
17
import eu.etaxonomy.dataportal.elements.BaseElement;
18 18
import eu.etaxonomy.dataportal.selenium.AllTrue;
19 19
import eu.etaxonomy.dataportal.selenium.UrlLoaded;
20 20
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
......
37 37
	@CacheLookup
38 38
	private WebElement keyTable;
39 39

  
40
	@FindBy(css="#identificationKey .sources span.reference")
41
	@CacheLookup
42
	private List<WebElement> sourceReferences;
43

  
44
	@FindBy(css="#identificationKey .annotations")
45
    @CacheLookup
46
    private WebElement annotations;
47

  
40 48
	private List<WebElement> keyTableRows;
41 49

  
42 50
	public PolytomousKeyPage(WebDriver driver, DataPortalContext context, UUID keyUuid) throws MalformedURLException {
......
52 60
		super(driver, context);
53 61
	}
54 62

  
63
	public String getKeyAnnotationsText(){
64
	    return annotations.getText();
65
	}
66

  
67
	public List<BaseElement> getSources() {
68
	    List<BaseElement> baseElements = new ArrayList<BaseElement>();
69
//	    List<WebElement> references = sources.findElements(By.className("reference"));
70
	    for(WebElement sr : sourceReferences) {
71
	        baseElements.add(new BaseElement(sr));
72
	    }
73
	    return baseElements;
74
	}
75

  
55 76
	public static class KeyLineData{
56 77

  
57 78
		String nodeNumber = null;
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/CyprusPolytomousKeyTest.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.dataportal.selenium.tests.cyprus;
11

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

  
15
import org.junit.Assert;
16
import org.junit.Test;
17

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

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

  
32
@DataPortalContexts({ DataPortalContext.cyprus })
33
public class CyprusPolytomousKeyTest extends CdmDataPortalTestBase {
34

  
35

  
36
    @Test
37
    public void key_to_Achillea() throws Exception {
38

  
39
        UUID keyUuid = UUID.fromString("9c2e7e3b-974f-412c-b1db-3078042a417b");
40

  
41
        PolytomousKeyPage p = new PolytomousKeyPage(driver, getContext(), keyUuid);
42

  
43
        PortalPage targetPage;
44
        KeyLineData keyLineData;
45

  
46

  
47
        Assert.assertEquals(getContext().prepareTitle("Achillea"), driver.getTitle());
48

  
49
        Assert.assertEquals("but modified, supplemented and names used differing", p.getKeyAnnotationsText());
50

  
51
        List<BaseElement> sourceRefs = p.getSources();
52

  
53
        Assert.assertEquals( "G. N. Hadjikyriakou, Aromatic and spicy plants in Cyprus. 2007", sourceRefs.get(0).getText());
54
        Assert.assertEquals(1, sourceRefs.get(0).getLinksInElement().size());
55

  
56
        Assert.assertEquals("R. D. Meikle, Flora of Cyprus 2. 1985", sourceRefs.get(1).getText());
57
        Assert.assertEquals(1, sourceRefs.get(1).getLinksInElement().size());
58

  
59
        // -------- //
60
        keyLineData = new KeyLineData("1",
61
                "Capitula without ligulate ray-florets; leaves entire or subentire",
62
                LinkClass.nodeLinkToTaxon, "Achillea maritima subsp. maritima");
63
        targetPage = p.followPolytomousKeyLine(0, keyLineData);
64
        Assert.assertEquals(getContext().prepareTitle(keyLineData.getLinkText()), driver.getTitle());
65
        // This page should also have a key tab
66
        Assert.assertEquals("Keys", targetPage.getPrimaryTabs().get(2).getText());
67
        p.get();
68

  
69
        // -------- //
70
        keyLineData = new KeyLineData("1'", "Capitula with ligulate ray-florets; leaves pinnatisect",
71
                LinkClass.nodeLinkToNode, "2");
72
//        targetPage = p.followPolytomousKeyLine(1, keyLineData);
73
//        Assert.assertEquals(p.getPageURL().getPath(), targetPage.getPageURL().getPath()); // TODO
74
//        p.get();
75

  
76

  
77
        keyLineData = new KeyLineData("2", "Ray-florets yellow", LinkClass.nodeLinkToNode, "3");
78
        keyLineData = new KeyLineData("2'", "Ray-florets white", LinkClass.nodeLinkToNode, "4");
79

  
80

  
81
    }
82

  
83
}
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/flMalesiana/FloraMalesianaPolytomousKeyTest.java
31 31
@DataPortalContexts({ DataPortalContext.floramalesiana })
32 32
public class FloraMalesianaPolytomousKeyTest extends CdmDataPortalTestBase {
33 33

  
34
    /**
35
     * see http://dev.e-taxonomy.eu/trac/ticket/2350
36
     * @throws Exception
37
     *
38
     */
39 34
    @Test
40
    @Ignore // imposible to test FloraMalesiana by now, database is changing too frequently
35
    @Ignore // impossible to test FloraMalesiana by now, database is changing too frequently
41 36
    public void key_to_Malaysian_Sapindaceae_Genera() throws Exception {
42 37

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

Also available in: Unified diff