Project

General

Profile

Download (4.09 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 java.util.List;
12
import java.util.UUID;
13

    
14
import org.junit.Before;
15
import org.junit.Test;
16
import org.openqa.selenium.By;
17
import org.openqa.selenium.WebElement;
18

    
19
import eu.etaxonomy.dataportal.DataPortalSite;
20
import eu.etaxonomy.dataportal.ElementUtils;
21
import eu.etaxonomy.dataportal.elements.GalleryImage;
22
import eu.etaxonomy.dataportal.elements.TaxonListElement;
23
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
24
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
25
import eu.etaxonomy.dataportal.pages.GenericPortalPage;
26
import eu.etaxonomy.dataportal.pages.PortalPage;
27
import eu.etaxonomy.dataportal.pages.TaxonSearchResultPage;
28
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
29
import junit.framework.Assert;
30

    
31
@DataPortalContexts( { DataPortalSite.cichorieae })
32
public class Cichorieae_SearchTest extends CdmDataPortalTestBase {
33

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

    
37

    
38
    @Before
39
    public void setUp() throws Exception {
40

    
41
        driver.get(getContext().getBaseUri().toString());
42
        homePage = new GenericPortalPage(driver, getContext());
43

    
44
    }
45

    
46
    // @Test
47
    public void testSearchLCommunis() throws Exception {
48

    
49
        TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
50

    
51
        assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
52

    
53
        TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
54

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

    
57
        WebElement nameElement = lapsanaCommunnis.getElement().findElement(By.className("TaxonName"));
58

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

    
63
        WebElement authorPart = nameElement.findElement(By.xpath("span[2]"));
64
        Assert.assertEquals("L.", authorPart.getText());
65
        Assert.assertEquals("normal", authorPart.getCssValue("font-style"));
66

    
67
        WebElement referenceElement = lapsanaCommunnis.getElement().findElement(By.className("reference"));
68
        Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
69

    
70
        PortalPage taxonProfilLapsanaCommunnis = searchResultPage.clickTaxonName(lapsanaCommunnis, GenericPortalPage.class, UUID_L_COMMUNIS);
71
        assertEquals(getContext().prepareTitle("Lapsana communis"), taxonProfilLapsanaCommunnis.getTitle());
72
    }
73

    
74
    @Test
75
    public void testSearchLCommunis_ImageLinks() throws Exception {
76

    
77
        TaxonSearchResultPage searchResultPage = homePage.submitQuery("Lapsana com*");
78

    
79
        assertEquals(getContext().prepareTitle("Search results"), searchResultPage.getTitle());
80

    
81
        TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
82

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

    
85
        assertEquals("Expecting one row of images", 1, galleryImageRows.size());
86
        assertEquals("Expecting 4 images in row", 4, galleryImageRows.get(0).size());
87

    
88
        GalleryImage firstImage = galleryImageRows.get(0).get(0);
89
        assertNull("caption should be off", firstImage.getCaptionText());
90
        if(searchResultPage.isZenTheme()) {
91
            firstImage.getImageLink().getUrl().equals("http://media.bgbm.org/erez/erez?src=EditWP6/photos/Lactuca_triquetra_Bc_01.JPG");
92
        } else {
93
            searchResultPage.clickLink(firstImage.getImageLink(), new VisibilityOfElementLocated(By.id("images")), GenericPortalPage.class);
94
        }
95
    }
96

    
97
}
(6-6/13)