I came across this problem a few years ago, and at the time there wasn't an easy way to get hold of the binaries using Maven. So I did what anybody who is into open source software would do: I wrote a plugin to do it for me.
This plugin will allow you to specify a series of driver binaries to automatically download and remove the manual setup steps. It also means that you can enforce the version of driver binaries that are used, which removes lots of intermittent issues caused by people using different versions of the binaries that can behave differently, on different machines.
We are now going to enhance our project structure so that it looks like this:
Let's start off by tweaking our POM; we will need a new property that we will call overwrite.binaries.
<properties> <project.build.sourceEncoding>UTF-8 </project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8 </project.reporting.outputEncoding> <!-- Dependency versions --> <selenium.version>2.45.0</selenium.version> <!-- Configurable variables --> <threads>1</threads> <browser>firefox</browser> <overwrite.binaries>false</overwrite.binaries>
</properties>
[ 28 ]
<plugin> <groupId>com.lazerycode.selenium</groupId> <artifactId>driver-binary-downloader-maven-plugin</artifactId> <version>1.0.7</version> <configuration>
<rootStandaloneServerDirectory>${project.basedir} /src/test/resources/selenium_standalone_binaries </rootStandaloneServerDirectory> <downloadedZipFileDirectory>${project.basedir} /src/test/resources/selenium_standalone_zips </downloadedZipFileDirectory> <customRepositoryMap>${project.basedir} /src/test/resources/RepositoryMap.xml </customRepositoryMap> <overwriteFilesThatExist>${ overwrite.binaries}</overwriteFilesThatExist>
</configuration> <executions>
<execution> <goals>
<goal>selenium</goal> </goals>
</execution> </executions>
</plugin>
Finally, we need to add some new system properties to our maven-failsafe-
plugin con guration:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.17</version> <configuration>
<parallel>methods</parallel> <threadCount>${threads}</threadCount> <systemProperties>
<browser>${browser}</browser> <!--Set properties passed in by the driver binary downloader-->
[ 29 ]
Chapter 1
We then need to add the driver-binary-downloader plugin:
Creating a Fast Feedback Loop
<webdriver.chrome.driver>${webdriver.chrome.driver} </webdriver.chrome.driver> <webdriver.ie.driver>${webdriver.ie.driver} </webdriver.ie.driver> <webdriver.opera.driver>${webdriver.opera.driver} </webdriver.opera.driver>
</systemProperties> <includes>
<include>**/*WD.java</include> </includes>
</configuration> <executions>
<execution> <goals>
<goal>integration-test</goal>
<goal>verify</goal> </goals>
</execution> </executions>
</plugin>
Comments
0 comments
Article is closed for comments.