Skip to content

Commit

Permalink
Serenity now downloads the webdriver binaries automatically if not pr…
Browse files Browse the repository at this point in the history
…esent

Added integration with WebDriverManager (https://github.com/bonigarcia/webdrivermanager), which allows the latest WebDriver binaries to be downloaded automatically if they are not present on the machine. You can disable this behaviour using the `automatic.driver.download` property.
  • Loading branch information
wakaleo committed Oct 27, 2016
1 parent 1de7a5c commit aec742d
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
23 changes: 15 additions & 8 deletions serenity-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.apache.tools.ant.filters.*

ext {
bintrayPackage = 'serenity-core'
}
Expand Down Expand Up @@ -60,11 +61,11 @@ dependencies {
exclude group: 'xml-apis', module: 'xml-apis'
}

compile("org.seleniumhq.selenium:htmlunit-driver:${htmlunitVersion}"){
compile("org.seleniumhq.selenium:htmlunit-driver:${htmlunitVersion}") {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
exclude group: 'org.seleniumhq.selenium', module: 'selenium-remote-driver'
exclude group: 'commons-codec', module: 'commons-codec'
exclude group: 'net.sourceforge.htmlunit', module:'htmlunit'
exclude group: 'net.sourceforge.htmlunit', module: 'htmlunit'
}

compile('io.appium:java-client:4.0.0') {
Expand Down Expand Up @@ -109,10 +110,10 @@ dependencies {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.apache.httpcomponents', module: 'httpmime'
}
compile ('org.apache.httpcomponents:httpclient:4.5.2') {
compile('org.apache.httpcomponents:httpclient:4.5.2') {
exclude group: 'commons-codec', module: 'commons-codec'
}
compile ('org.apache.httpcomponents:httpmime:4.5.2'){
compile('org.apache.httpcomponents:httpmime:4.5.2') {
exclude group: 'commons-codec', module: 'commons-codec'
}

Expand All @@ -122,7 +123,7 @@ dependencies {
}
compile "com.jhlabs:filters:2.0.235"
compile("org.asciidoctor:asciidoctor-java-integration:0.1.4") {
exclude group: 'com.beust', module:'jcommander'
exclude group: 'com.beust', module: 'jcommander'
}

compile 'org.imgscalr:imgscalr-lib:4.2'
Expand All @@ -135,10 +136,10 @@ dependencies {
compile "org.objenesis:objenesis:2.1"
compile "xml-apis:xml-apis:1.4.01"
compile("xalan:xalan:2.7.2") {
exclude group: 'xalan', module:'serializer'
exclude group: 'xalan', module: 'serializer'
}
compile("xalan:serializer:2.7.2") {
exclude group: 'xml-apis', module:'xml-apis'
exclude group: 'xml-apis', module: 'xml-apis'
}

compile('com.jayway.awaitility:awaitility:1.6.3') {
Expand All @@ -148,10 +149,16 @@ dependencies {
compile('org.jsoup:jsoup:1.8.3') {
exclude group: 'junit', module: 'junit'
}
compile ('com.google.jimfs:jimfs:1.0') {
compile('com.google.jimfs:jimfs:1.0') {
exclude group: 'com.google.guava', module: 'guava'
}

compile('io.github.bonigarcia:webdrivermanager:1.4.10') {
exclude group: 'org.slf4j', module: 'slf4j-api'
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'org.jsoup', module: 'jsoup'
}

testCompile "junit:junit:${junitVersion}"
testCompile "org.springframework:spring-test:${springVersion}"
testCompile "org.springframework:spring-context:${springVersion}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.serenitybdd.core.webdriver.servicepools;

import io.github.bonigarcia.wdm.ChromeDriverManager;
import net.thucydides.core.ThucydidesSystemProperty;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
Expand Down Expand Up @@ -35,10 +37,16 @@ protected ChromeDriverService newDriverService() {
}

private File chromeDriverExecutable() {
return DriverServiceExecutable.called("chromedriver")

if (ThucydidesSystemProperty.AUTOMATIC_DRIVER_DOWNLOAD.booleanFrom(environmentVariables, true)) {
ChromeDriverManager.getInstance().setup();
}
File executable = DriverServiceExecutable.called("chromedriver")
.withSystemProperty(WEBDRIVER_CHROME_DRIVER.getPropertyName())
.usingEnvironmentVariables(environmentVariables)
.andDownloadableFrom("https://sites.google.com/a/chromium.org/chromedriver/downloads")
.asAFile();

return executable;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.serenitybdd.core.webdriver.servicepools;

import io.github.bonigarcia.wdm.EdgeDriverManager;
import net.thucydides.core.ThucydidesSystemProperty;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
Expand Down Expand Up @@ -36,6 +38,10 @@ protected EdgeDriverService newDriverService() {
}

private File edgeDriverExecutable() {
if (ThucydidesSystemProperty.AUTOMATIC_DRIVER_DOWNLOAD.booleanFrom(environmentVariables, true)) {
EdgeDriverManager.getInstance().setup();
}

return DriverServiceExecutable.called("MicrosoftWebDriver.exe")
.withSystemProperty(WEBDRIVER_EDGE_DRIVER.getPropertyName())
.usingEnvironmentVariables(environmentVariables)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package net.serenitybdd.core.webdriver.servicepools;

import net.thucydides.core.ThucydidesSystemProperty;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.github.bonigarcia.wdm.MarionetteDriverManager;

import java.io.File;

Expand Down Expand Up @@ -34,6 +36,10 @@ protected GeckoDriverService newDriverService() {
}

private void configureGeckoDriverBinaries() {
if (ThucydidesSystemProperty.AUTOMATIC_DRIVER_DOWNLOAD.booleanFrom(environmentVariables, true)) {
MarionetteDriverManager.getInstance().setup();
}

File geckoBinary = GeckoDriverServiceExecutable.inEnvironment(environmentVariables);
DriverPathConfiguration.updateSystemProperty(WEBDRIVER_GECKO_DRIVER.getPropertyName())
.withExecutablePath(geckoBinary);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.serenitybdd.core.webdriver.servicepools;

import io.github.bonigarcia.wdm.InternetExplorerDriverManager;
import net.thucydides.core.ThucydidesSystemProperty;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
Expand Down Expand Up @@ -36,6 +38,10 @@ protected InternetExplorerDriverService newDriverService() {
}

private File driverExecutable() {
if (ThucydidesSystemProperty.AUTOMATIC_DRIVER_DOWNLOAD.booleanFrom(environmentVariables, true)) {
InternetExplorerDriverManager.getInstance().setup();
}

return DriverServiceExecutable.called("IEDriverServer.exe")
.withSystemProperty(WEBDRIVER_IE_DRIVER.getPropertyName())
.usingEnvironmentVariables(environmentVariables)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.serenitybdd.core.webdriver.servicepools;

import io.github.bonigarcia.wdm.PhantomJsDriverManager;
import net.thucydides.core.ThucydidesSystemProperty;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
Expand All @@ -26,6 +28,10 @@ protected PhantomJSDriverService newDriverService() {
}

private File phantomJSBinary() {
if (ThucydidesSystemProperty.AUTOMATIC_DRIVER_DOWNLOAD.booleanFrom(environmentVariables, true)) {
PhantomJsDriverManager.getInstance().setup();
}

return DriverServiceExecutable.called("phantomjs")
.usingEnvironmentVariables(environmentVariables)
.withSystemProperty(PHANTOMJS_BINARY_PATH.getPropertyName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,12 @@ public enum ThucydidesSystemProperty {
*/
SERENITY_WEBDRIVER_COLLECTION_LOADING_STRATEGY("serenity.webdriver.collection_loading_strategy"),

/**
* Serenity will try to download drivers not present on the system.
* If you don't want this behaviour, set this property to false
*/
AUTOMATIC_DRIVER_DOWNLOAD,

/**
* If the Gecko Driver is on the system path, it will be used (with Marionnette) by default.
* If you want to use the old-style Firefox driver, but have gecko on the system path,
Expand Down Expand Up @@ -910,4 +916,5 @@ public Boolean booleanFrom(EnvironmentVariables environmentVariables, Boolean de
public boolean isDefinedIn(EnvironmentVariables environmentVariables) {
return StringUtils.isNotEmpty(from(environmentVariables));
}

}

0 comments on commit aec742d

Please sign in to comment.