From 921838f766c08573e2b69fdf9a42ae5d42f86618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Papou=C5=A1ek?= Date: Tue, 14 May 2013 14:49:10 +0200 Subject: [PATCH] ARQ-1424: support for phantom driver resolving phantomjs binary --- depchain/webdriver/pom.xml | 6 ++--- drone-build/pom.xml | 16 ++++++++++---- drone-webdriver/pom.xml | 4 ++-- .../factory/PhantomJSDriverFactory.java | 22 +++++++++++++------ .../src/test/resources/arquillian.xml | 2 +- pom.xml | 2 ++ 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/depchain/webdriver/pom.xml b/depchain/webdriver/pom.xml index f4a213ad..ecc880c3 100644 --- a/depchain/webdriver/pom.xml +++ b/depchain/webdriver/pom.xml @@ -118,9 +118,9 @@ ${version.com.opera} - com.github.detro.ghostdriver - phantomjsdriver - ${version.com.github.detro.ghostdriver} + org.jboss.arquillian.extension + arquillian-phantom-driver + ${version.phantom.driver} diff --git a/drone-build/pom.xml b/drone-build/pom.xml index 54c0f3fb..5fecad44 100644 --- a/drone-build/pom.xml +++ b/drone-build/pom.xml @@ -148,6 +148,15 @@ + + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-bom + ${version.shrinkwrap_resolver} + pom + import + + org.jboss.arquillian @@ -194,11 +203,10 @@ - com.github.detro.ghostdriver - phantomjsdriver - ${version.com.github.detro.ghostdriver} + org.jboss.arquillian.extension + arquillian-phantom-driver + ${version.phantom.driver} - diff --git a/drone-webdriver/pom.xml b/drone-webdriver/pom.xml index df1bbec3..05133916 100644 --- a/drone-webdriver/pom.xml +++ b/drone-webdriver/pom.xml @@ -109,8 +109,8 @@ provided - com.github.detro.ghostdriver - phantomjsdriver + org.jboss.arquillian.extension + arquillian-phantom-driver provided diff --git a/drone-webdriver/src/main/java/org/jboss/arquillian/drone/webdriver/factory/PhantomJSDriverFactory.java b/drone-webdriver/src/main/java/org/jboss/arquillian/drone/webdriver/factory/PhantomJSDriverFactory.java index c9310e88..94b07ea2 100644 --- a/drone-webdriver/src/main/java/org/jboss/arquillian/drone/webdriver/factory/PhantomJSDriverFactory.java +++ b/drone-webdriver/src/main/java/org/jboss/arquillian/drone/webdriver/factory/PhantomJSDriverFactory.java @@ -16,14 +16,17 @@ */ package org.jboss.arquillian.drone.webdriver.factory; +import java.io.IOException; import org.jboss.arquillian.drone.spi.Configurator; import org.jboss.arquillian.drone.spi.Destructor; import org.jboss.arquillian.drone.spi.Instantiator; import org.jboss.arquillian.drone.webdriver.configuration.WebDriverConfiguration; +import org.jboss.arquillian.phantom.resolver.ResolvingPhantomJSDriverService; import org.openqa.selenium.Capabilities; import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.phantomjs.PhantomJSDriverService; import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.service.DriverService; /** * Factory which combines {@link org.jboss.arquillian.drone.spi.Configurator}, @@ -78,17 +81,22 @@ public PhantomJSDriver createInstance(WebDriverConfiguration configuration) { if (Validate.empty(driverBinary)) { driverBinary = SecurityActions.getProperty(PHANTOMJS_DRIVER_BINARY_KEY); + capabilities.setCapability(PHANTOMJS_DRIVER_BINARY_KEY, driverBinary); } - // driver binary configuration + // create an instance with the resolving binary if (Validate.nonEmpty(driverBinary)) { - Validate.isValidPath(driverBinary, "PhantomJS driver binary must represent a valid path, " + driverBinary); - Validate.isExecutable(driverBinary, "PhantomJS driver binary must point to an executable file, " + driverBinary); + try { + return SecurityActions.newInstance(configuration.getImplementationClass(), new Class[] { DriverService.class, Capabilities.class }, + new Object[] { ResolvingPhantomJSDriverService.createDefaultService(capabilities), capabilities }, PhantomJSDriver.class); + } catch (IOException e) { + throw new IllegalStateException("Unable to create an instance of " + configuration.getImplementationClass() + ".", e); + } + // create an instance with the common behaviour + } else { + return SecurityActions.newInstance(configuration.getImplementationClass(), new Class[] { Capabilities.class }, + new Object[] { capabilities }, PhantomJSDriver.class); } - - // create the instance - return SecurityActions.newInstance(configuration.getImplementationClass(), new Class[] { Capabilities.class }, - new Object[] { capabilities }, PhantomJSDriver.class); } @Override diff --git a/drone-webdriver/src/test/resources/arquillian.xml b/drone-webdriver/src/test/resources/arquillian.xml index 35d13eb1..cb1d1356 100644 --- a/drone-webdriver/src/test/resources/arquillian.xml +++ b/drone-webdriver/src/test/resources/arquillian.xml @@ -54,7 +54,7 @@ phantomjs - + target/phantomjs diff --git a/pom.xml b/pom.xml index adcc28bf..d1caff47 100644 --- a/pom.xml +++ b/pom.xml @@ -38,12 +38,14 @@ 1.0.3.Final 1.1 1.0.3 + 1.0.4-SNAPSHOT 2.31.0 1.5 1.5 + 2.0.0-beta-3