Project

General

Profile

Download (4.19 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.assertEquals;
13
import static org.junit.Assert.assertNull;
14

    
15
import java.util.List;
16
import java.util.UUID;
17

    
18
import junit.framework.Assert;
19

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

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

    
36
@DataPortalContexts( { DataPortalContext.cichorieae })
37
public class Cichorieae_SearchTest extends CdmDataPortalTestBase {
38

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

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

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

    
48
    }
49

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
101
}
(6-6/13)