1
|
package eu.etaxonomy.dataportal.pages;
|
2
|
|
3
|
import java.net.MalformedURLException;
|
4
|
import java.net.URL;
|
5
|
|
6
|
import org.apache.log4j.Logger;
|
7
|
import org.openqa.selenium.RenderedWebElement;
|
8
|
import org.openqa.selenium.WebDriver;
|
9
|
import org.openqa.selenium.support.CacheLookup;
|
10
|
import org.openqa.selenium.support.FindBy;
|
11
|
import org.openqa.selenium.support.PageFactory;
|
12
|
|
13
|
import eu.etaxonomy.dataportal.TestConfiguration;
|
14
|
import eu.etaxonomy.dataportal.selenium.JUnitWebDriverWait;
|
15
|
|
16
|
public class PortalPage {
|
17
|
|
18
|
public static final Logger logger = Logger.getLogger(PortalPage.class);
|
19
|
|
20
|
protected WebDriver driver;
|
21
|
protected final JUnitWebDriverWait wait;
|
22
|
protected URL initialUrl;
|
23
|
|
24
|
@FindBy(id= "cdm_dataportal.node")
|
25
|
@CacheLookup
|
26
|
private RenderedWebElement portalContent;
|
27
|
|
28
|
@FindBy(tagName= "title")
|
29
|
@CacheLookup
|
30
|
private RenderedWebElement title;
|
31
|
|
32
|
public PortalPage(WebDriver driver) throws MalformedURLException {
|
33
|
this.driver = driver;
|
34
|
this.initialUrl = new URL(driver.getCurrentUrl());
|
35
|
this.wait = new JUnitWebDriverWait(driver, 25);
|
36
|
|
37
|
logger.info("loading " + initialUrl);
|
38
|
}
|
39
|
|
40
|
public void goToInitialPage() {
|
41
|
driver.get(initialUrl.toString());
|
42
|
PageFactory.initElements(driver, this);
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* returns the string from the <code>title</code> tag.
|
47
|
* @return
|
48
|
*/
|
49
|
public String getTitle() {
|
50
|
return title.getText();
|
51
|
}
|
52
|
|
53
|
|
54
|
/**
|
55
|
* Returns the current URL string from the {@link WebDriver}
|
56
|
* @return
|
57
|
*/
|
58
|
public String getURL() {
|
59
|
return driver.getCurrentUrl();
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* return the <code>scheme://domain:port</code> part of the initial url of this page.
|
64
|
* @return
|
65
|
*/
|
66
|
public String getInitialUrlBase() {
|
67
|
return initialUrl.getProtocol() + "://" + initialUrl.getHost() + initialUrl.getPort();
|
68
|
}
|
69
|
|
70
|
public boolean equals(Object obj) {
|
71
|
if (PortalPage.class.isAssignableFrom(obj.getClass())) {
|
72
|
PortalPage page = (PortalPage) obj;
|
73
|
return this.getURL().equals(page.getURL());
|
74
|
|
75
|
} else {
|
76
|
return false;
|
77
|
}
|
78
|
}
|
79
|
|
80
|
}
|