commit f0d48bd8d19bfaa4f7a31469a9c278516c6ba0c0
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Mon Oct 6 09:39:21 2014 +0000

    test for #4423 (DescriptionElement media no longer visible)

diff --git a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/ElementUtils.java b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/ElementUtils.java
index 45131501..843eb22b 100644
--- a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/ElementUtils.java
+++ b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/ElementUtils.java
@@ -12,11 +12,18 @@ package eu.etaxonomy.dataportal;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.log4j.Logger;
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
 import eu.etaxonomy.dataportal.elements.BaseElement;
+import eu.etaxonomy.dataportal.elements.GalleryImage;
 import eu.etaxonomy.dataportal.elements.LinkElement;
+import eu.etaxonomy.dataportal.pages.PortalPage;
+import eu.etaxonomy.dataportal.selenium.AllTrue;
+import eu.etaxonomy.dataportal.selenium.ChildElementVisible;
+import eu.etaxonomy.dataportal.selenium.JUnitWebDriverWait;
 
 /**
  * @author andreas
@@ -25,28 +32,85 @@ import eu.etaxonomy.dataportal.elements.LinkElement;
  */
 public class ElementUtils {
 
-	/**
-	 * @param fnListElements
-	 * @return
-	 */
-	public static List<BaseElement> baseElementsFromFootNoteListElements(List<WebElement> fnListElements) {
-		List<BaseElement> footNotes = new ArrayList<BaseElement>();
-		for(WebElement fn : fnListElements) {
-			footNotes.add(new BaseElement(fn));
-		}
-		return footNotes;
-	}
-
-	/**
-	 * @param fnkListElements
-	 * @return
-	 */
-	public static List<LinkElement> linkElementsFromFootNoteKeyListElements(List<WebElement> fnkListElements) {
-		List<LinkElement> footNoteKeys = new ArrayList<LinkElement>();
-		for(WebElement fnk : fnkListElements) {
-			footNoteKeys.add(new LinkElement(fnk));
-		}
-		return footNoteKeys;
-	}
+
+    public static final Logger logger = Logger.getLogger(ElementUtils.class);
+
+    /**
+     * @param fnListElements
+     * @return
+     */
+    public static List<BaseElement> baseElementsFromFootNoteListElements(List<WebElement> fnListElements) {
+        List<BaseElement> footNotes = new ArrayList<BaseElement>();
+        for(WebElement fn : fnListElements) {
+            footNotes.add(new BaseElement(fn));
+        }
+        return footNotes;
+    }
+
+    /**
+     * @param fnkListElements
+     * @return
+     */
+    public static List<LinkElement> linkElementsFromFootNoteKeyListElements(List<WebElement> fnkListElements) {
+        List<LinkElement> footNoteKeys = new ArrayList<LinkElement>();
+        for(WebElement fnk : fnkListElements) {
+            footNoteKeys.add(new LinkElement(fnk));
+        }
+        return footNoteKeys;
+    }
+
+    /**
+     * @param wait
+     * @return a two dimensional array representing the media items in the gallery, or null if no gallery exists.
+     */
+    public static List<List<GalleryImage>> getGalleryImages(WebElement webElement, WebDriverWait wait) {
+
+
+        WebElement gallery = webElement.findElement(By.className("media_gallery"));
+
+        if( gallery == null){
+            return null;
+        }
+
+        ArrayList<List<GalleryImage>> galleryImageRows = new ArrayList<List<GalleryImage>>();
+
+        List<WebElement> tableRows = gallery.findElements(By.tagName("tr"));
+        logger.debug("GalleryImages - total rows " + tableRows.size());
+        // loop table rows
+        for(int rowId = 0; rowId * 2 < tableRows.size() && tableRows.size() > 0; rowId++ ){
+            logger.debug("GalleryImages - gallery row " + rowId );
+            List<WebElement> imageCells = tableRows.get(rowId * 2).findElements(By.tagName("td"));
+            logger.debug("GalleryImages - number of image cells: " + imageCells.size());
+            List<WebElement> captionCells = null;
+            if(tableRows.size() > rowId * 2 + 1){
+                captionCells = tableRows.get(rowId * 2 + 1).findElements(By.tagName("td"));
+                logger.debug("GalleryImages - number of caption cells: " + captionCells.size());
+            }
+
+            galleryImageRows.add(new ArrayList<GalleryImage>());
+
+            // loop table cells in row
+            for(int cellId = 0; cellId < imageCells.size(); cellId++) {
+                logger.debug("cellId:" + cellId);
+                WebElement imageCell = imageCells.get(cellId);
+                WebElement captionCell = null;
+                if(captionCells != null && captionCells.size() > cellId){
+                    captionCell = captionCells.get(cellId);
+                    wait.until(new AllTrue(
+                            new ChildElementVisible(imageCell, By.tagName("img")),
+                            new ChildElementVisible(captionCell, By.tagName("dl"))
+                    ));
+
+                } else {
+                    wait.until(new ChildElementVisible(imageCell, By.tagName("img")));
+                }
+                galleryImageRows.get(rowId).add(new GalleryImage(imageCell, captionCell));
+            }
+
+        }
+
+        return galleryImageRows;
+    }
+
 
 }
diff --git a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java
index 3b5551f0..3a4c45b6 100644
--- a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java
+++ b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/elements/FeatureBlock.java
@@ -154,4 +154,11 @@ public class FeatureBlock extends DrupalBlock {
         }
     }
 
+    public List<GalleryImage> getGalleryMedia() {
+        List<GalleryImage> galleryImages = null; //getGalleryImages(getElement());
+
+        return galleryImages;
+
+    }
+
 }
diff --git a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/GenericPortalPage.java b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/GenericPortalPage.java
index af437d5b..a60cf346 100644
--- a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/GenericPortalPage.java
+++ b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/GenericPortalPage.java
@@ -10,12 +10,17 @@
 package eu.etaxonomy.dataportal.pages;
 
 import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
 
 import eu.etaxonomy.dataportal.DataPortalContext;
+import eu.etaxonomy.dataportal.elements.GalleryImage;
 import eu.etaxonomy.dataportal.selenium.AllTrue;
+import eu.etaxonomy.dataportal.selenium.ChildElementVisible;
 import eu.etaxonomy.dataportal.selenium.PageTitleValidated;
 import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
 
diff --git a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSearchResultPage.java b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSearchResultPage.java
index 432a7355..cf3fb712 100644
--- a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSearchResultPage.java
+++ b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSearchResultPage.java
@@ -22,11 +22,8 @@ import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.FindBy;
 
 import eu.etaxonomy.dataportal.DataPortalContext;
-import eu.etaxonomy.dataportal.elements.GalleryImage;
 import eu.etaxonomy.dataportal.elements.LinkElement;
 import eu.etaxonomy.dataportal.elements.TaxonListElement;
-import eu.etaxonomy.dataportal.selenium.AllTrue;
-import eu.etaxonomy.dataportal.selenium.ChildElementVisible;
 import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated;
 
 /**
@@ -116,58 +113,6 @@ public class TaxonSearchResultPage extends GenericPortalPage {
 
     }
 
-    /**
-     * @return a two dimensional array representing the media items in the gallery, or null if no gallery exists.
-     */
-    public List<List<GalleryImage>> getGalleryImagesOf(TaxonListElement taxonListElement) {
-
-
-        WebElement gallery = taxonListElement.getElement().findElement(By.className("media_gallery"));
-
-        if( gallery == null){
-            return null;
-        }
-
-        ArrayList<List<GalleryImage>> galleryImageRows = new ArrayList<List<GalleryImage>>();
-
-        List<WebElement> tableRows = gallery.findElements(By.tagName("tr"));
-        logger.debug("GalleryImages - total rows " + tableRows.size());
-        // loop table rows
-        for(int rowId = 0; rowId * 2 < tableRows.size() && tableRows.size() > 0; rowId++ ){
-            logger.debug("GalleryImages - gallery row " + rowId );
-            List<WebElement> imageCells = tableRows.get(rowId * 2).findElements(By.tagName("td"));
-            logger.debug("GalleryImages - number of image cells: " + imageCells.size());
-            List<WebElement> captionCells = null;
-            if(tableRows.size() > rowId * 2 + 1){
-                captionCells = tableRows.get(rowId * 2 + 1).findElements(By.tagName("td"));
-                logger.debug("GalleryImages - number of caption cells: " + captionCells.size());
-            }
-
-            galleryImageRows.add(new ArrayList<GalleryImage>());
-
-            // loop table cells in row
-            for(int cellId = 0; cellId < imageCells.size(); cellId++) {
-                logger.debug("cellId:" + cellId);
-                WebElement imageCell = imageCells.get(cellId);
-                WebElement captionCell = null;
-                if(captionCells != null && captionCells.size() > cellId){
-                    captionCell = captionCells.get(cellId);
-                    wait.until(new AllTrue(
-                            new ChildElementVisible(imageCell, By.tagName("img")),
-                            new ChildElementVisible(captionCell, By.tagName("dl"))
-                    ));
-
-                } else {
-                    wait.until(new ChildElementVisible(imageCell, By.tagName("img")));
-                }
-                galleryImageRows.get(rowId).add(new GalleryImage(imageCell, captionCell));
-            }
-
-        }
-
-        return galleryImageRows;
-    }
-
 
 
 }
diff --git a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_SearchTest.java b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_SearchTest.java
index 1fd98f97..3dc0204a 100644
--- a/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_SearchTest.java
+++ b/7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_SearchTest.java
@@ -23,6 +23,7 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
 
 import eu.etaxonomy.dataportal.DataPortalContext;
+import eu.etaxonomy.dataportal.ElementUtils;
 import eu.etaxonomy.dataportal.elements.GalleryImage;
 import eu.etaxonomy.dataportal.elements.TaxonListElement;
 import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
@@ -87,7 +88,7 @@ public class Cichorieae_SearchTest extends CdmDataPortalTestBase {
 
         TaxonListElement lapsanaCommunnis = searchResultPage.getResultItem(1);
 
-        List<List<GalleryImage>> galleryImageRows = searchResultPage.getGalleryImagesOf(lapsanaCommunnis);
+        List<List<GalleryImage>> galleryImageRows = ElementUtils.getGalleryImages(lapsanaCommunnis.getElement(), searchResultPage.getWait());
 
         assertEquals("Expecting one row of images", 1, galleryImageRows.size());
         assertEquals("Expecting 4 images in row", 4, galleryImageRows.get(0).size());
