1
|
package eu.etaxonomy.dataportal.selenium;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
|
5
|
import junit.framework.Assert;
|
6
|
|
7
|
import org.junit.After;
|
8
|
import org.junit.Before;
|
9
|
import org.junit.Test;
|
10
|
import org.openqa.selenium.By;
|
11
|
import org.openqa.selenium.WebDriver;
|
12
|
import org.openqa.selenium.WebElement;
|
13
|
import org.openqa.selenium.chrome.ChromeDriver;
|
14
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
15
|
import org.openqa.selenium.firefox.FirefoxProfile;
|
16
|
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
17
|
import org.openqa.selenium.ie.InternetExplorerDriver;
|
18
|
|
19
|
public class SearchLCommunis {
|
20
|
|
21
|
private static final String FIREBUG_VERSION = "1.6.2";
|
22
|
|
23
|
WebDriver driver;
|
24
|
|
25
|
static String baseUrl = "http://wp6-cichorieae.e-taxonomy.eu/portal/";
|
26
|
|
27
|
@Before
|
28
|
public void setUpDriver() {
|
29
|
|
30
|
driver = initFirefoxDriver();
|
31
|
}
|
32
|
|
33
|
private WebDriver initChromeDriver() {
|
34
|
//System.setProperty("webdriver.chrome.bin", "C:\\Dokumente und Einstellungen\\a.kohlbecker.BGBM\\Lokale Einstellungen\\Anwendungsdaten\\Google\\Chrome\\Application\\chrome.exe");
|
35
|
return new ChromeDriver();
|
36
|
}
|
37
|
|
38
|
private WebDriver initInternetExplorerDriver() {
|
39
|
return new InternetExplorerDriver();
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* -Dwebdriver.firefox.bin=/usr/lib/iceweasel/firefox-bin
|
44
|
*
|
45
|
* See http://code.google.com/p/selenium/wiki/FirefoxDriverInternals
|
46
|
* @return
|
47
|
*/
|
48
|
private WebDriver initFirefoxDriver() {
|
49
|
//System.setProperty("webdriver.firefox.bin", "C:\\Programme\\Mozilla Firefox 3\\firefox.exe");
|
50
|
//System.out.println("##:" + System.getProperty("webdriver.firefox.bin"));
|
51
|
FirefoxProfile firefoxProfile = new FirefoxProfile();
|
52
|
try {
|
53
|
|
54
|
firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/firebug-" + FIREBUG_VERSION + ".xpi");
|
55
|
firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION); // avoid displaying firt run page
|
56
|
|
57
|
// --- allow enabling incompatible addons
|
58
|
// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi");
|
59
|
// firefoxProfile.setPreference("extensions.acr.firstrun", false);
|
60
|
// firefoxProfile.setPreference("extensions.enabledAddons", "fxdriver@googlecode.com,compatibility@addons.mozilla.org:0.8.3,fxdriver@googlecode.com:0.9.7376,{CAFEEFAC-0016-0000-0024-ABCDEFFEDCBA}:6.0.24,{20a82645-c095-46ed-80e3-08825760534b}:0.0.0,meetinglauncher@iconf.net:4.10.12.316,jqs@sun.com:1.0,{972ce4c6-7e08-4474-a285-3208198ce6fd}:4.0");
|
61
|
// firefoxProfile.setPreference("extensions.checkCompatibility", false);
|
62
|
// firefoxProfile.setPreference("extensions.checkCompatibility.4.0", false);
|
63
|
// firefoxProfile.setPreference("extensions.checkCompatibility.4.1", false);
|
64
|
|
65
|
|
66
|
|
67
|
} catch (IOException e) {
|
68
|
// TODO Auto-generated catch block
|
69
|
e.printStackTrace();
|
70
|
System.exit(-1);
|
71
|
}
|
72
|
driver = new FirefoxDriver(firefoxProfile);
|
73
|
|
74
|
return driver;
|
75
|
}
|
76
|
|
77
|
@After
|
78
|
public void closeDriver() {
|
79
|
driver.quit();
|
80
|
}
|
81
|
|
82
|
@Test
|
83
|
public void testSearchLCommunis() throws Exception {
|
84
|
driver.get(baseUrl + "?query=Lapsana+com*&search[tree]=534e190f-3339-49ba-95d9-fa27d5493e3e&q=cdm_dataportal%2Fsearch%2Ftaxon&search[pageSize]=25&search[pageNumber]=0&search[doTaxa]=1&search[doSynonyms]=1&search[doTaxaByCommonNames]=0");
|
85
|
WebElement taxonElement = driver.findElement(By.xpath("/html/body/div/div/div[2]/div[2]/div/div/div/ul/li/span[@ref='/name/f280f79f-5903-47b0-8352-53e4204c6cf1']"));
|
86
|
|
87
|
WebElement nameElement = taxonElement.findElement(By.className("BotanicalName"));
|
88
|
Assert.assertEquals("Lapsana", nameElement.findElement(By.xpath("span[1]")).getText());
|
89
|
Assert.assertEquals("communis", nameElement.findElement(By.xpath("span[2]")).getText());
|
90
|
Assert.assertEquals("L.", nameElement.findElement(By.xpath("span[3]")).getText());
|
91
|
|
92
|
WebElement referenceElement = taxonElement.findElement(By.className("reference"));
|
93
|
Assert.assertEquals("Sp. Pl.: 811. 1753", referenceElement.findElement((By.className("reference"))).getText());
|
94
|
}
|
95
|
|
96
|
|
97
|
}
|