Skip to content

Commit

Permalink
ARQ-1424: support for phantom driver resolving phantomjs binary
Browse files Browse the repository at this point in the history
  • Loading branch information
papousek authored and Lukas Fryc committed Jul 3, 2013
1 parent e367137 commit 921838f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
6 changes: 3 additions & 3 deletions depchain/webdriver/pom.xml
Expand Up @@ -118,9 +118,9 @@
<version>${version.com.opera}</version>
</dependency>
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>${version.com.github.detro.ghostdriver}</version>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-phantom-driver</artifactId>
<version>${version.phantom.driver}</version>
</dependency>
</dependencies>

Expand Down
16 changes: 12 additions & 4 deletions drone-build/pom.xml
Expand Up @@ -148,6 +148,15 @@

<dependencyManagement>
<dependencies>
<!-- override the version from Arquillian BOM -->
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-bom</artifactId>
<version>${version.shrinkwrap_resolver}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Arquillian -->
<dependency>
<groupId>org.jboss.arquillian</groupId>
Expand Down Expand Up @@ -194,11 +203,10 @@

<!-- PhanthomJS dependencies not present in the Selenium BOM file -->
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>${version.com.github.detro.ghostdriver}</version>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-phantom-driver</artifactId>
<version>${version.phantom.driver}</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
4 changes: 2 additions & 2 deletions drone-webdriver/pom.xml
Expand Up @@ -109,8 +109,8 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-phantom-driver</artifactId>
<scope>provided</scope>
</dependency>

Expand Down
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drone-webdriver/src/test/resources/arquillian.xml
Expand Up @@ -54,7 +54,7 @@

<extension qualifier="webdriver-phantomjs">
<property name="browserCapabilities">phantomjs</property>
<!-- <property name="phantomjs.binary.path">/opt/phantomjs/phantomjs</property> -->
<property name="phantomjs.binary.path">target/phantomjs</property>
</extension>

<!-- ARQ-1030 -->
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Expand Up @@ -38,12 +38,14 @@
<version.arquillian.core>1.0.3.Final</version.arquillian.core>
<version.com.opera>1.1</version.com.opera>
<version.com.github.detro.ghostdriver>1.0.3</version.com.github.detro.ghostdriver>
<version.phantom.driver>1.0.4-SNAPSHOT</version.phantom.driver>
<version.selenium>2.31.0</version.selenium>

<!-- override from parent -->
<maven.compiler.argument.target>1.5</maven.compiler.argument.target>
<maven.compiler.argument.source>1.5</maven.compiler.argument.source>

<version.shrinkwrap_resolver>2.0.0-beta-3</version.shrinkwrap_resolver>
</properties>

<build>
Expand Down

0 comments on commit 921838f

Please sign in to comment.