Project

General

Profile

Download (4 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.dataportal.selenium.tests.cichorieae;
11

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

    
15
import java.util.List;
16

    
17
import junit.framework.Assert;
18

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

    
24
import eu.etaxonomy.dataportal.DataPortalContext;
25
import eu.etaxonomy.dataportal.elements.GalleryImage;
26
import eu.etaxonomy.dataportal.elements.LinkElement;
27
import eu.etaxonomy.dataportal.elements.TaxonListElement;
28
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
29
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
30
import eu.etaxonomy.dataportal.pages.GenericPortalPage;
31
import eu.etaxonomy.dataportal.pages.PortalPage;
32
import eu.etaxonomy.dataportal.pages.TaxonSearchResultPage;
33
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
34

    
35
@DataPortalContexts( { DataPortalContext.cichorieae })
36
public class CichorieaeSearchTest extends CdmDataPortalTestBase {
37

    
38
    private static GenericPortalPage homePage = null;
39

    
40
    @Before
41
    public void setUp() throws Exception {
42

    
43
        driver.get(getContext().getBaseUri().toString());
44
        homePage = new GenericPortalPage(driver, getContext());
45

    
46
    }
47

    
48
    @Test
49
    public void testSearchLCommunis() throws Exception {
50

    
51
        TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
52

    
53
        assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
54

    
55
        TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
56

    
57
        assertEquals("Lapsana communis L., Sp. Pl.: 811. 1753", lapsanaCommunnis.getFullTaxonName());
58

    
59
        WebElement nameElement = lapsanaCommunnis.getElement().findElement(By.className("BotanicalName"));
60

    
61
        WebElement namePart1 = nameElement.findElement(By.xpath("span[1]"));
62
        Assert.assertEquals("Lapsana", namePart1.getText());
63
        Assert.assertEquals("italic", namePart1.getCssValue("font-style"));
64

    
65
        WebElement namePart2 = nameElement.findElement(By.xpath("span[2]"));
66
        Assert.assertEquals("communis", namePart2.getText());
67
        Assert.assertEquals("italic", namePart2.getCssValue("font-style"));
68

    
69
        WebElement authorPart = nameElement.findElement(By.xpath("span[3]"));
70
        Assert.assertEquals("L.", authorPart.getText());
71
        Assert.assertEquals("normal", authorPart.getCssValue("font-style"));
72

    
73
        WebElement referenceElement = lapsanaCommunnis.getElement().findElement(By.className("reference"));
74
        Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
75

    
76
        PortalPage taxonProfilLapsanaCommunnis = searchResultPage.clickTaxonName(lapsanaCommunnis, PortalPage.class);
77
        assertEquals(getContext().prepareTitle("Lapsana communis"), taxonProfilLapsanaCommunnis.getTitle());
78
    }
79

    
80
    @Test
81
    public void testSearchLCommunis_ImageLinks() throws Exception {
82

    
83
        TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
84

    
85
        assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
86

    
87
        TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
88

    
89
        List<List<GalleryImage>> galleryImageRows = searchResultPage.getGalleryImagesOf(lapsanaCommunnis);
90

    
91
        assertEquals("Expecting one row of images", 1, galleryImageRows.size());
92
        assertEquals("Expecting 4 images in row", 4, galleryImageRows.get(0).size());
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
    }
98

    
99
}
(1-1/9)