Project

General

Profile

« Previous | Next » 

Revision 8e677507

Added by Andreas Kohlbecker over 3 years ago

ref #8543 improving zen_dataportal theme detection

View differences:

src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java
28 28
import org.openqa.selenium.support.PageFactory;
29 29
import org.openqa.selenium.support.ui.WebDriverWait;
30 30

  
31
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
31 32
import com.google.common.base.Function;
32 33

  
33 34
import eu.etaxonomy.dataportal.DataPortalContext;
......
110 111

  
111 112
    public boolean isZenTheme() {
112 113
        if(isZenTheme == null) {
113
            isZenTheme = driver.getPageSource().contains("themes/zen_dataportal");
114
            try {
115
                WebElement bodyElement = driver.findElement(By.tagName("body"));
116
                isZenTheme = bodyElement.getAttribute("class").contains("zen_dataportal");
117
            } catch (ElementNotFoundException e) {
118
                // IGNORE
119
            }
114 120
        }
115 121
        return isZenTheme.booleanValue();
116 122
    }
src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_SearchTest.java
25 25
import eu.etaxonomy.dataportal.pages.GenericPortalPage;
26 26
import eu.etaxonomy.dataportal.pages.PortalPage;
27 27
import eu.etaxonomy.dataportal.pages.TaxonSearchResultPage;
28
import eu.etaxonomy.dataportal.selenium.UrlLoaded;
29 28
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
30 29
import junit.framework.Assert;
31 30

  
......
89 88
        GalleryImage firstImage = galleryImageRows.get(0).get(0);
90 89
        assertNull("caption should be off", firstImage.getCaptionText());
91 90
        if(searchResultPage.isZenTheme()) {
92
            searchResultPage.clickLink(firstImage.getImageLink(), new UrlLoaded("http://media.bgbm.org/erez/erez?src=EditWP6/photos/Lactuca_triquetra_Bc_01.JPG"), null);
91
            firstImage.getImageLink().getUrl().equals("http://media.bgbm.org/erez/erez?src=EditWP6/photos/Lactuca_triquetra_Bc_01.JPG");
93 92
        } else {
94 93
            searchResultPage.clickLink(firstImage.getImageLink(), new VisibilityOfElementLocated(By.id("images")), GenericPortalPage.class);
95 94
        }
src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java
62 62
        List<LinkElement> primaryTabs = p.getPrimaryTabs();
63 63
        int tabId = 0;
64 64
        if(p.isZenTheme()) {
65
            assertEquals("General", primaryTabs.get(tabId++).getText());
65
            assertEquals("General\n(active tab)", primaryTabs.get(tabId++).getText());
66 66
        } else {
67 67
            // old garland theme
68
            assertEquals("General\n(active tab)", primaryTabs.get(tabId++).getText());
68
            assertEquals("General", primaryTabs.get(tabId++).getText());
69 69
        }
70 70
        assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
71 71
        assertEquals("Images", primaryTabs.get(tabId++).getText());
themes/zen_dataportal/template.php
242 242
  _set_image_url('page_background', $variables, NULL, '#page');
243 243
  _set_image_url('banner', $variables, 'banner.jpg', '#header', "scroll no-repeat; background-color: white; background-clip: content-box");
244 244
  _add_inline_styles($variables);
245

  
245
  // add class attribute zen_dataportal for theme detection during tests
246
  $variables['classes_array'][] = 'zen_dataportal';
246 247
}
247 248

  
248 249
/**

Also available in: Unified diff