Project

General

Profile

Download (4.18 KB) Statistics
| Branch: | Tag: | Revision:
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.cichorieae;
10

    
11
import static org.junit.Assert.assertEquals;
12
import static org.junit.Assert.assertNull;
13

    
14
import java.util.List;
15
import java.util.UUID;
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.ElementUtils;
26
import eu.etaxonomy.dataportal.elements.GalleryImage;
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 Cichorieae_SearchTest extends CdmDataPortalTestBase {
37

    
38
    private static final UUID UUID_L_COMMUNIS = UUID.fromString("5d65f017-0c23-43e4-888d-9649de50dd45");
39
    private static GenericPortalPage homePage = null;
40

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

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

    
47
    }
48

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
90
        List<List<GalleryImage>> galleryImageRows = ElementUtils.getGalleryImages(lapsanaCommunnis.getElement(), searchResultPage.getWait());
91

    
92
        assertEquals("Expecting one row of images", 1, galleryImageRows.size());
93
        assertEquals("Expecting 4 images in row", 4, galleryImageRows.get(0).size());
94

    
95
        GalleryImage firstImage = galleryImageRows.get(0).get(0);
96
        assertNull("caption should be off", firstImage.getCaptionText());
97
        searchResultPage.clickLink(firstImage.getImageLink(), new VisibilityOfElementLocated(By.id("images")), GenericPortalPage.class);
98
    }
99

    
100
}
(6-6/13)