1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.dataportal.selenium;
|
5
|
|
6
|
import java.io.IOException;
|
7
|
|
8
|
import org.junit.AfterClass;
|
9
|
import org.junit.BeforeClass;
|
10
|
import org.junit.runner.RunWith;
|
11
|
import org.openqa.selenium.WebDriver;
|
12
|
import org.openqa.selenium.chrome.ChromeDriver;
|
13
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
14
|
import org.openqa.selenium.firefox.FirefoxProfile;
|
15
|
import org.openqa.selenium.ie.InternetExplorerDriver;
|
16
|
|
17
|
import eu.etaxonomy.dataportal.DataPortalContextAwareRunner;
|
18
|
|
19
|
/**
|
20
|
* @author a.kohlbecker
|
21
|
*
|
22
|
*/
|
23
|
@RunWith(DataPortalContextAwareRunner.class)
|
24
|
public abstract class CdmDataPortalTestBase {
|
25
|
|
26
|
private static final String FIREBUG_VERSION = "1.6.2";
|
27
|
|
28
|
protected static WebDriver driver;
|
29
|
|
30
|
@BeforeClass
|
31
|
public static void setUpDriver() {
|
32
|
driver = initFirefoxDriver();
|
33
|
}
|
34
|
|
35
|
|
36
|
@AfterClass
|
37
|
public static void closeDriver() {
|
38
|
if(driver != null){
|
39
|
driver.quit();
|
40
|
}
|
41
|
}
|
42
|
|
43
|
public WebDriver initChromeDriver() {
|
44
|
//System.setProperty("webdriver.chrome.bin", "C:\\Dokumente und Einstellungen\\a.kohlbecker.BGBM\\Lokale Einstellungen\\Anwendungsdaten\\Google\\Chrome\\Application\\chrome.exe");
|
45
|
return new ChromeDriver();
|
46
|
}
|
47
|
|
48
|
public WebDriver initInternetExplorerDriver() {
|
49
|
return new InternetExplorerDriver();
|
50
|
}
|
51
|
|
52
|
/**
|
53
|
* -Dwebdriver.firefox.bin=/usr/lib/iceweasel/firefox-bin
|
54
|
*
|
55
|
* See http://code.google.com/p/selenium/wiki/FirefoxDriverInternals
|
56
|
* @return
|
57
|
*/
|
58
|
public static WebDriver initFirefoxDriver() {
|
59
|
//System.setProperty("webdriver.firefox.bin", "C:\\Programme\\Mozilla Firefox 3\\firefox.exe");
|
60
|
//System.out.println("##:" + System.getProperty("webdriver.firefox.bin"));
|
61
|
FirefoxProfile firefoxProfile = new FirefoxProfile();
|
62
|
try {
|
63
|
|
64
|
firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firebug-" + FIREBUG_VERSION + ".xpi");
|
65
|
firefoxProfile.setPreference("extensions.firebug.currentVersion", FIREBUG_VERSION); // avoid displaying firt run page
|
66
|
|
67
|
// --- allow enabling incompatible addons
|
68
|
// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi");
|
69
|
// firefoxProfile.setPreference("extensions.acr.firstrun", false);
|
70
|
// 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");
|
71
|
// firefoxProfile.setPreference("extensions.checkCompatibility", false);
|
72
|
// firefoxProfile.setPreference("extensions.checkCompatibility.4.0", false);
|
73
|
// firefoxProfile.setPreference("extensions.checkCompatibility.4.1", false);
|
74
|
|
75
|
} catch (IOException e) {
|
76
|
// TODO Auto-generated catch block
|
77
|
e.printStackTrace();
|
78
|
System.exit(-1);
|
79
|
}
|
80
|
driver = new FirefoxDriver(firefoxProfile);
|
81
|
|
82
|
return driver;
|
83
|
}
|
84
|
|
85
|
|
86
|
}
|