1
|
package eu.etaxonomy.dataportal.elements;
|
2
|
|
3
|
import java.net.MalformedURLException;
|
4
|
import java.net.URL;
|
5
|
|
6
|
import org.openqa.selenium.Dimension;
|
7
|
import org.openqa.selenium.WebElement;
|
8
|
|
9
|
public class ImgElement extends BaseElement {
|
10
|
|
11
|
private URL srcUrl = null;
|
12
|
private Dimension dimension = null;
|
13
|
private String altText = null;
|
14
|
|
15
|
public ImgElement(WebElement img) {
|
16
|
|
17
|
super(img);
|
18
|
|
19
|
// read src url
|
20
|
if (img.getAttribute("src") != null) {
|
21
|
try {
|
22
|
setSrcUrl(new URL(img.getAttribute("src")));
|
23
|
} catch (MalformedURLException e) {
|
24
|
// IGNORE //
|
25
|
}
|
26
|
}
|
27
|
|
28
|
// read rendered width & height
|
29
|
setDimension(img.getSize());
|
30
|
|
31
|
setAltText(img.getAttribute("alt"));
|
32
|
}
|
33
|
|
34
|
public void setSrcUrl(URL url) {
|
35
|
this.srcUrl = url;
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* Returns the image source URL from the src attribute
|
40
|
* @return
|
41
|
*/
|
42
|
public URL getSrcUrl() {
|
43
|
return srcUrl;
|
44
|
}
|
45
|
|
46
|
public void setDimension(Dimension dimension) {
|
47
|
this.dimension = dimension;
|
48
|
}
|
49
|
|
50
|
public Dimension getDimension() {
|
51
|
return dimension;
|
52
|
}
|
53
|
|
54
|
public void setAltText(String altText) {
|
55
|
this.altText = altText;
|
56
|
}
|
57
|
|
58
|
public String getAltText() {
|
59
|
return altText;
|
60
|
}
|
61
|
|
62
|
|
63
|
}
|