|
|
|
@ -63,54 +63,47 @@ class WebDriverPool {
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public void configure() throws IOException {
|
|
|
|
|
try{
|
|
|
|
|
// Read config file
|
|
|
|
|
sConfig = new Properties();
|
|
|
|
|
String configFile = DEFAULT_CONFIG_FILE;
|
|
|
|
|
if (System.getProperty("selenuim_config")!=null){
|
|
|
|
|
configFile = System.getProperty("selenuim_config");
|
|
|
|
|
|
|
|
|
|
// Read config file
|
|
|
|
|
sConfig = new Properties();
|
|
|
|
|
String configFile = DEFAULT_CONFIG_FILE;
|
|
|
|
|
if (System.getProperty("selenuim_config")!=null){
|
|
|
|
|
configFile = System.getProperty("selenuim_config");
|
|
|
|
|
}
|
|
|
|
|
sConfig.load(new FileReader(configFile));
|
|
|
|
|
|
|
|
|
|
// Prepare capabilities
|
|
|
|
|
sCaps = new DesiredCapabilities();
|
|
|
|
|
sCaps.setJavascriptEnabled(true);
|
|
|
|
|
sCaps.setCapability("takesScreenshot", false);
|
|
|
|
|
|
|
|
|
|
String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
|
|
|
|
|
|
|
|
|
|
// Fetch PhantomJS-specific configuration parameters
|
|
|
|
|
if (driver.equals(DRIVER_PHANTOMJS)) {
|
|
|
|
|
// "phantomjs_exec_path"
|
|
|
|
|
if (sConfig.getProperty("phantomjs_exec_path") != null) {
|
|
|
|
|
sCaps.setCapability(
|
|
|
|
|
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
|
|
|
|
|
sConfig.getProperty("phantomjs_exec_path"));
|
|
|
|
|
} else {
|
|
|
|
|
throw new IOException(
|
|
|
|
|
String.format(
|
|
|
|
|
"Property '%s' not set!",
|
|
|
|
|
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
|
|
|
|
|
}
|
|
|
|
|
FileReader configFileReader = new FileReader(configFile)
|
|
|
|
|
sConfig.load(configFileReader);
|
|
|
|
|
|
|
|
|
|
// Prepare capabilities
|
|
|
|
|
sCaps = new DesiredCapabilities();
|
|
|
|
|
sCaps.setJavascriptEnabled(true);
|
|
|
|
|
sCaps.setCapability("takesScreenshot", false);
|
|
|
|
|
String driver = sConfig.getProperty("driver", DRIVER_PHANTOMJS);
|
|
|
|
|
// Fetch PhantomJS-specific configuration parameters
|
|
|
|
|
if (driver.equals(DRIVER_PHANTOMJS)) {
|
|
|
|
|
// "phantomjs_exec_path"
|
|
|
|
|
if (sConfig.getProperty("phantomjs_exec_path") != null) {
|
|
|
|
|
sCaps.setCapability(
|
|
|
|
|
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
|
|
|
|
|
sConfig.getProperty("phantomjs_exec_path"));
|
|
|
|
|
} else {
|
|
|
|
|
throw new IOException(
|
|
|
|
|
String.format(
|
|
|
|
|
"Property '%s' not set!",
|
|
|
|
|
PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY));
|
|
|
|
|
}
|
|
|
|
|
// "phantomjs_driver_path"
|
|
|
|
|
if (sConfig.getProperty("phantomjs_driver_path") != null) {
|
|
|
|
|
System.out.println("Test will use an external GhostDriver");
|
|
|
|
|
sCaps.setCapability(
|
|
|
|
|
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY,
|
|
|
|
|
sConfig.getProperty("phantomjs_driver_path"));
|
|
|
|
|
} else {
|
|
|
|
|
System.out
|
|
|
|
|
.println("Test will use PhantomJS internal GhostDriver");
|
|
|
|
|
}
|
|
|
|
|
// "phantomjs_driver_path"
|
|
|
|
|
if (sConfig.getProperty("phantomjs_driver_path") != null) {
|
|
|
|
|
System.out.println("Test will use an external GhostDriver");
|
|
|
|
|
sCaps.setCapability(
|
|
|
|
|
PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_PATH_PROPERTY,
|
|
|
|
|
sConfig.getProperty("phantomjs_driver_path"));
|
|
|
|
|
} else {
|
|
|
|
|
System.out
|
|
|
|
|
.println("Test will use PhantomJS internal GhostDriver");
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
throw new IOException("Can not load config file properly");
|
|
|
|
|
|
|
|
|
|
}finally{
|
|
|
|
|
configFileReader.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Disable "web-security", enable all possible "ssl-protocols" and
|
|
|
|
|
// "ignore-ssl-errors" for PhantomJSDriver
|
|
|
|
|
// sCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new
|
|
|
|
|