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.selenium.JUnitWebDriverWait;
|
14
|
|
15
|
public class PortalPage {
|
16
|
|
17
|
public static final Logger logger = Logger.getLogger(PortalPage.class);
|
18
|
|
19
|
protected WebDriver driver;
|
20
|
protected final JUnitWebDriverWait wait;
|
21
|
protected URL initialUrl;
|
22
|
|
23
|
@FindBy(id= "cdm_dataportal.node")
|
24
|
@CacheLookup
|
25
|
private RenderedWebElement portalContent;
|
26
|
|
27
|
@FindBy(tagName= "title")
|
28
|
@CacheLookup
|
29
|
private RenderedWebElement title;
|
30
|
|
31
|
public PortalPage(WebDriver driver) throws MalformedURLException {
|
32
|
this.driver = driver;
|
33
|
this.initialUrl = new URL(driver.getCurrentUrl());
|
34
|
this.wait = new JUnitWebDriverWait(driver, 25);
|
35
|
logger.info("new " + this.getClass().getSimpleName() + " for " + initialUrl);
|
36
|
}
|
37
|
|
38
|
public void goToInitialPage() {
|
39
|
driver.get(initialUrl.toString());
|
40
|
PageFactory.initElements(driver, this);
|
41
|
}
|
42
|
|
43
|
public String getTitle() {
|
44
|
return title.getText();
|
45
|
}
|
46
|
|
47
|
public String getURL() {
|
48
|
return driver.getCurrentUrl();
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* return the <code>scheme://domain:port</code> part of the initial url of this page.
|
53
|
* @return
|
54
|
*/
|
55
|
public String getInitialUrlBase() {
|
56
|
return initialUrl.getProtocol() + "://" + initialUrl.getHost() + initialUrl.getPort();
|
57
|
}
|
58
|
|
59
|
public boolean equals(Object obj) {
|
60
|
if (PortalPage.class.isAssignableFrom(obj.getClass())) {
|
61
|
PortalPage page = (PortalPage) obj;
|
62
|
return this.getTitle().equals(page.getTitle())
|
63
|
&& this.getURL().equals(page.getURL());
|
64
|
|
65
|
} else {
|
66
|
return false;
|
67
|
}
|
68
|
}
|
69
|
|
70
|
}
|