Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2011 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.elements;
10

    
11
import org.apache.log4j.Level;
12
import org.openqa.selenium.By;
13
import org.openqa.selenium.NoSuchElementException;
14
import org.openqa.selenium.WebElement;
15

    
16

    
17
/**
18
 * @author andreas
19
 * @since Jul 4, 2011
20
 *
21
 */
22
public class DrupalBlock extends BaseElement {
23

    
24
	WebElement titleElement;
25

    
26

    
27
	public DrupalBlock(WebElement element) {
28
	    this(element, false);
29
	}
30

    
31
	public DrupalBlock(WebElement element, boolean hasHiddenTitle) {
32

    
33
		super(element);
34

    
35
		logger.setLevel(Level.TRACE);
36
        logger.trace("DrupalBlock() - constructor after super()");
37

    
38
		try {
39
		    titleElement = element.findElement(By.className("block-title"));
40
		} catch (NoSuchElementException e){
41
		    try {
42
		        titleElement = element.findElement(By.className("title"));
43
		    } catch  (NoSuchElementException e2){
44
		        if(!hasHiddenTitle){
45
		            throw e2;
46
		        }
47
		    }
48
		}
49
	}
50

    
51
	public String getHeaderText() {
52
		return titleElement.getText();
53
	}
54

    
55
	public String getContentText() {
56
	    String titleText = getHeaderText();
57
	    String elementText = getElement().getText();
58
	    if(elementText.startsWith(titleText)){
59
	        elementText = elementText.substring(titleText.length(), elementText.length());
60
	    }
61
		return elementText;
62
	}
63

    
64
}
(5-5/20)