Project

General

Profile

Download (1.4 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2011 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10

    
11
package eu.etaxonomy.dataportal.elements;
12

    
13
import static org.junit.Assert.assertEquals;
14

    
15
import org.openqa.selenium.WebElement;
16

    
17
/**
18
 * @author andreas
19
 * @date Jul 1, 2011
20
 *
21
 */
22
public class LinkElement extends BaseElement {
23

    
24
	private String href = null;
25
	public String getUrl() {
26
		return href;
27
	}
28

    
29
	public void setHref(String href) {
30
		this.href = href;
31
	}
32

    
33

    
34
	public LinkElement(WebElement a) {
35

    
36
		super(a);
37

    
38
		if(!a.getTagName().equals("a")){
39
			throw new RuntimeException("Invalid WebElement: <" + a.getTagName() + "> given, but must be <a>");
40
		}
41

    
42
		// read src url
43
		if (a.getAttribute("href") != null) {
44
				setHref(a.getAttribute("href"));
45
		}
46

    
47
	}
48

    
49
	@Override
50
	public String toSting(){
51
		return super.toSting() + ": " + getUrl() + "";
52
	}
53

    
54
	public static boolean testIfLinkElement(BaseElement element, String text, String href) {
55
		return testIfLinkElement(element.getElement(), text, href);
56
	}
57

    
58
	public static boolean testIfLinkElement(WebElement element, String text, String href) {
59
		assertEquals("a", element.getTagName());
60
		assertEquals(href, element.getAttribute("href"));
61
		assertEquals(text, element.getText());
62
		return true;
63
	}
64

    
65
}
(7-7/11)