Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
1 6657531f Andreas Kohlbecker
/**
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 59fe3c8e Andreas Kohlbecker
import org.apache.log4j.Level;
12 6657531f Andreas Kohlbecker
import org.openqa.selenium.By;
13
import org.openqa.selenium.NoSuchElementException;
14
import org.openqa.selenium.WebElement;
15
16
17
/**
18
 * @author andreas
19 e37e4d0c Andreas Kohlbecker
 * @since Jul 4, 2011
20 6657531f Andreas Kohlbecker
 *
21
 */
22
public class DrupalBlock extends BaseElement {
23
24 ee5d420b Andreas Kohlbecker
	WebElement titleElement;
25 57e125ea Andreas Kohlbecker
26 e37e4d0c Andreas Kohlbecker
27 6657531f Andreas Kohlbecker
	public DrupalBlock(WebElement element) {
28 ee5d420b Andreas Kohlbecker
	    this(element, false);
29
	}
30
31
	public DrupalBlock(WebElement element, boolean hasHiddenTitle) {
32 6657531f Andreas Kohlbecker
33
		super(element);
34
35 59fe3c8e Andreas Kohlbecker
		logger.setLevel(Level.TRACE);
36
        logger.trace("DrupalBlock() - constructor after super()");
37
38 6657531f Andreas Kohlbecker
		try {
39 ee5d420b Andreas Kohlbecker
		    titleElement = element.findElement(By.className("block-title"));
40 6657531f Andreas Kohlbecker
		} catch (NoSuchElementException e){
41 ee5d420b Andreas Kohlbecker
		    try {
42
		        titleElement = element.findElement(By.className("title"));
43
		    } catch  (NoSuchElementException e2){
44
		        if(!hasHiddenTitle){
45
		            throw e2;
46
		        }
47
		    }
48 6657531f Andreas Kohlbecker
		}
49
	}
50
51 ee5d420b Andreas Kohlbecker
	public String getHeaderText() {
52
		return titleElement.getText();
53 6657531f Andreas Kohlbecker
	}
54
55 ee5d420b Andreas Kohlbecker
	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 6657531f Andreas Kohlbecker
	}
63
64
}