Revision 14a1655f
Added by Andreas Kohlbecker over 10 years ago
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/GenericPortalPage.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.dataportal.pages; |
11 | 11 |
|
12 | 12 |
import java.net.MalformedURLException; |
13 |
import java.sql.PreparedStatement; |
|
14 |
import java.util.List; |
|
15 | 13 |
|
16 |
import org.junit.Assert; |
|
17 | 14 |
import org.openqa.selenium.By; |
18 | 15 |
import org.openqa.selenium.WebDriver; |
19 |
import org.openqa.selenium.WebElement; |
|
20 |
|
|
21 |
import com.google.common.base.Function; |
|
22 | 16 |
|
23 | 17 |
import eu.etaxonomy.dataportal.DataPortalContext; |
24 |
import eu.etaxonomy.dataportal.elements.ClassificationTreeBlock; |
|
25 | 18 |
import eu.etaxonomy.dataportal.selenium.AllTrue; |
26 | 19 |
import eu.etaxonomy.dataportal.selenium.PageTitleValidated; |
27 |
import eu.etaxonomy.dataportal.selenium.UrlLoaded; |
|
28 | 20 |
import eu.etaxonomy.dataportal.selenium.VisibilityOfElementLocated; |
29 | 21 |
|
30 | 22 |
/** |
... | ... | |
69 | 61 |
searchBlockElement.findElement(By.id("edit-query")).sendKeys(query); |
70 | 62 |
searchBlockElement.findElement(By.id("edit-submit")).submit();//Search results |
71 | 63 |
|
72 |
wait.until(new AllTrue(new PageTitleValidated(context.prepareTitle("Search results")), new VisibilityOfElementLocated(By.id("container")))); |
|
64 |
wait.until( |
|
65 |
new AllTrue( |
|
66 |
new PageTitleValidated(context.prepareTitle("Search results")), |
|
67 |
new VisibilityOfElementLocated(By.id("container")) |
|
68 |
) |
|
69 |
); |
|
73 | 70 |
return new TaxonSearchResultPage(driver, context); |
74 | 71 |
} |
75 | 72 |
|
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/AllTrue.java | ||
---|---|---|
17 | 17 |
*/ |
18 | 18 |
public class AllTrue implements Function<WebDriver, Boolean> { |
19 | 19 |
|
20 |
List<Function<WebDriver, Boolean>> functions = new ArrayList<Function<WebDriver, Boolean>>(); |
|
21 |
|
|
22 |
public AllTrue(Function<WebDriver, Boolean> ... functions) { |
|
23 |
if(functions == null){ |
|
24 |
throw new NullPointerException("Constructor parameter mus not be null"); |
|
25 |
} |
|
26 |
this.functions = Arrays.asList(functions); |
|
27 |
} |
|
28 |
|
|
29 |
/* (non-Javadoc) |
|
30 |
* @see com.google.common.base.Function#apply(java.lang.Object) |
|
31 |
*/ |
|
32 |
public Boolean apply(WebDriver driver) { |
|
33 |
Boolean allTrue = true; |
|
34 |
for(Function<WebDriver, Boolean> f : functions){ |
|
35 |
allTrue &= f.apply(driver); |
|
36 |
} |
|
37 |
return allTrue; |
|
38 |
} |
|
20 |
List<Function<WebDriver, Boolean>> functions = new ArrayList<Function<WebDriver, Boolean>>(); |
|
21 |
|
|
22 |
public AllTrue(Function<WebDriver, Boolean> ... functions) { |
|
23 |
if(functions == null){ |
|
24 |
throw new NullPointerException("Constructor parameter mus not be null"); |
|
25 |
} |
|
26 |
this.functions = Arrays.asList(functions); |
|
27 |
} |
|
28 |
|
|
29 |
/* (non-Javadoc) |
|
30 |
* @see com.google.common.base.Function#apply(java.lang.Object) |
|
31 |
*/ |
|
32 |
@Override |
|
33 |
public Boolean apply(WebDriver driver) { |
|
34 |
Boolean allTrue = true; |
|
35 |
for(Function<WebDriver, Boolean> f : functions){ |
|
36 |
allTrue &= f.apply(driver); |
|
37 |
} |
|
38 |
return allTrue; |
|
39 |
} |
|
39 | 40 |
|
40 | 41 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/PageTitleValidated.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.dataportal.selenium; |
5 | 5 |
|
6 |
import org.openqa.selenium.By; |
|
7 | 6 |
import org.openqa.selenium.WebDriver; |
8 | 7 |
|
9 | 8 |
import com.google.common.base.Function; |
... | ... | |
14 | 13 |
*/ |
15 | 14 |
public class PageTitleValidated implements Function<WebDriver, Boolean> { |
16 | 15 |
|
17 |
private String title;
|
|
16 |
private final String title;
|
|
18 | 17 |
|
19 |
public PageTitleValidated(String title) {
|
|
20 |
this.title = title;
|
|
21 |
}
|
|
18 |
public PageTitleValidated(String title) {
|
|
19 |
this.title = title;
|
|
20 |
}
|
|
22 | 21 |
|
23 |
/* (non-Javadoc) |
|
24 |
* @see com.google.common.base.Function#apply(java.lang.Object) |
|
25 |
*/ |
|
26 |
public Boolean apply(WebDriver driver) { |
|
27 |
boolean validated = driver.findElement(By.tagName("title")).getText().equals(title); |
|
28 |
return Boolean.valueOf(validated); |
|
29 |
} |
|
22 |
/* (non-Javadoc) |
|
23 |
* @see com.google.common.base.Function#apply(java.lang.Object) |
|
24 |
*/ |
|
25 |
@Override |
|
26 |
public Boolean apply(WebDriver driver) { |
|
27 |
boolean validated = driver.getTitle().equals(title); |
|
28 |
return Boolean.valueOf(validated); |
|
29 |
} |
|
30 | 30 |
|
31 | 31 |
} |
7.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/VisibilityOfElementLocated.java | ||
---|---|---|
14 | 14 |
*/ |
15 | 15 |
public class VisibilityOfElementLocated implements Function<WebDriver, Boolean> { |
16 | 16 |
|
17 |
By findCondition;
|
|
17 |
By findCondition;
|
|
18 | 18 |
|
19 |
public VisibilityOfElementLocated(By by) {
|
|
20 |
this.findCondition = by;
|
|
21 |
}
|
|
19 |
public VisibilityOfElementLocated(By by) {
|
|
20 |
this.findCondition = by;
|
|
21 |
}
|
|
22 | 22 |
|
23 |
/* (non-Javadoc) |
|
24 |
* @see com.google.common.base.Function#apply(java.lang.Object) |
|
25 |
*/ |
|
26 |
public Boolean apply(WebDriver driver) { |
|
27 |
driver.findElement(this.findCondition); |
|
28 |
return Boolean.valueOf(true); |
|
29 |
} |
|
23 |
/* (non-Javadoc) |
|
24 |
* @see com.google.common.base.Function#apply(java.lang.Object) |
|
25 |
*/ |
|
26 |
@Override |
|
27 |
public Boolean apply(WebDriver driver) { |
|
28 |
driver.findElement(this.findCondition); |
|
29 |
return Boolean.valueOf(true); |
|
30 |
} |
|
30 | 31 |
|
31 | 32 |
} |
Also available in: Unified diff
adapting test framwork to changes in selenium api