A Gradle template for JUnit Selenium WebDriver tests
Java Shell Groovy
Latest commit 6519246 Sep 3, 2013 @djangofan Update README.md
Permalink
Failed to load latest commit information.
commonlib Changes to get build working again on Gradle 1.7 Aug 1, 2013
google For report destination and new selenium version. Aug 18, 2013
parallelwebdriver Minor change for IE tests. Aug 18, 2013
.gitattributes Initial commit. Nov 19, 2012
.gitignore Change to .gitignore Sep 2, 2013
.project For report destination and new selenium version. Aug 18, 2013
LICENSE Initial commit. Nov 19, 2012
README.md Update README.md Sep 3, 2013
build.gradle Changes to get build working again on Gradle 1.7 Aug 1, 2013
clean.bat Change to project layout to regular include. Apr 3, 2013
gradle-app.setting Change to project layout to regular include. Apr 3, 2013
hubConfig.json Updates to work with IntelliJ IDEA Jul 25, 2013
hubConfigLinux.json Updates to work with IntelliJ IDEA Jul 25, 2013
membrane_proxy_config.xml Updates to work with IntelliJ IDEA Jul 25, 2013
node1Config.json For report destination and new selenium version. Aug 18, 2013
node1ConfigLinux.json For report destination and new selenium version. Aug 18, 2013
runProjectMenu.bat Fixed runProjectMenu menu items. Apr 3, 2013
settings.gradle Minor changes. Aug 3, 2013
startWebDriverGridHub.bat For report destination and new selenium version. Aug 18, 2013
startWebDriverGridHub.sh For report destination and new selenium version. Aug 18, 2013
startWebDriverGridNode.bat For report destination and new selenium version. Aug 18, 2013
startWebDriverGridNode.sh For report destination and new selenium version. Aug 18, 2013

README.md

IMPORTANT

This project is no longer maintained. Now, please see this GitHub repo instead: selenium-gradle-example

Info

This is a Java project that can be used as a template (or archetype) to start a WebDriver web browser testing project. I chose to simplify and and implement using simply WebDriver and Gradle.

I am very much interested in others forking my code and/or letting me know how it can be improved.

Versions

Version 1.0 - March 16, 2013

Project Layout

Eclipse Root
+--- Project ':root'
+--- Project ':sub-project'
+--- Project ':commonlib'
+--- Project ':google'
+--- Project ':parallelwebdriver'
+--- ...

Overview

1. Project "sub-project" is a project you add yourself, if you 
   want.
2. Project "google" is a RemoteWebDriver JUnit test-suite using
   a local Grid server that is capable of running multiple 
   threads of web browser tests.
3. Project "parallelwebdriver" is a test of a  multi-window 
   multi-threaded run using a static local website.
4. Project "commonlib" is a sub-project containing methods 
   shared between projects.
5. Project "root" is an 'includeFlat' Gradle-layout-alias to
   Eclipse project-root-dir 'WebDriverTestingTemplate'.

SubProjects

Links to sub-projects that belong to this project:

ParallelWebDriver

Google Example Tests

Quick Start

Normally, this project would be ran through the Gradle plugin for Eclipse IDE, but I have tried to make it easier by including a method to run dynamically and directly from the .zip distribution on the command line.

To try this project without requiring a Java IDE, just make sure you download Gradle 1.4, configure your GRADLE_HOME environment variable, add %GRADLE_HOME%\bin to your PATH, and then download the .zip distribution of this project, unzip it, and run the included root/runProjectMenu.bat script.

Implemented Features

Feature Description
JUnit based For use ONLY with JUnit 4.11 or higher because of the usage of the parameterized capability of JUnit. This dependency is configured by the Gradle build script.
Parallel runner
using JUnit
A parallel runner using the Gradle maxParallelForks method.
Native automation support For use with Sikuli 1.0.1 or higher to test native elements that WebDriver "Action" is unable to control. This dependency is configured in the Gradle build script. If you implement this however, you may not be able to use the remote webdriver option in your project.
Uses RemoteWebDriver
JSON Hub Server
I have included an implementation of a WebDriverServer class that starts a RemoteWebDriver JSON Hub server instance in the BeforeClass method of tests. This server is a static member of the utility class that the tests extend.
Parameterized data
driven capability
Unit tests are parameterized from a csv file. Can also load tests from XML, XLS, a database, etc.
Logging and Reporting Logs test output to console and to a file using SLF4j/LogBack API, and configured by a logback.xml file. Will generate reports of JUnit test results at build/reports/test/index.html . Will place a junit.log file at build/logs/junit.log .
Page Object design
pattern
Uses the WebDriver "page object" design pattern, enhanced by the Selenium "LoadableComponent" extendable class.
Fluent API design
pattern
Implemented examples of the Fluent API design pattern while retaining capability of the traditional page object pattern.
Multi-project build
configuration
Implemented multiple project build. The root project has a subproject called "core" and all subprojects of "core" inherit classes from it.
Run Options You have three different options for running the tests: via the Gradle GUI, via your IDE Gradle plugin, or via Gradle command line. To run with the JUnit runner in your IDE, you would need to manually export your project as a normal Java project, because this template does not support that.
Core utility package All projects inherit from a "core" project that contains classes where you can store methods that all of your projects can share between them.

Un-implemented Features

Feature Description
Gradle Wrapper Did not choose to implement the Gradle wrapper because I believe that downloading Gradle and configuring GRADLE_HOME and PATH are easy enough. Also, a manual setup of Gradle gives us more control using a batch script. Also, the development IDE is usually configured to use the statically defined Gradle home.
Jar executable option Creates an uberJar of all projects and subprojects that can be ran by double clicking the .jar file. If you don't have the file association supporting it, we include a jarAssociation.bat file to setup the file association on your Windows system. I was planning to implement this but currently having trouble getting it to work.

Configuration And Setup

Eclipse

To get it working on a regular Eclipse 4.2.1 or later, follow these steps:

1. Using the "Eclipse Marketplace" settings panel under the 
   Eclipse "Help" menu, install the Gradle tooling 
   functionality.  You can do it through the "Install New
   Software" menu, but it isn't recommended.  If Market is
   missing from your Eclipse, then add the repo:
   http://download.eclipse.org/releases/juno
   and then install the "market" and restart Eclipse.
2. Download the .zip archive of this GitHub project 
   distribution and unzip it to your workspace.  An example:
   "C:\Eclipse32\workspace\WebDriverTestingTemplate\" .
3. Use the Eclipse "Import" function from the Eclipse "File
   menu" to import a "Project" of type "Gradle".
4. Browse using the import wizard to your projects "root" 
   directory.  Then click the "Build model" button.
5. Check all checkboxes .  You could also choose to add all 
   to your "working set" if you like but it isn't required.
6. Rebuild the dependencies by right clicking on the project
   and then choose Gradle-->Refresh All Dependencies
7. Right click on your project and choose "Run As-->External
   Tools Configuration".  Configure a new "clean" and "build"
   configuration for running a sub-project (or whatever tasks
   you want to execute).
8. Optionally, you can run this project on the command line
   with "gradle google:show google:clean google:build --info" 
   and it will execute the project unit tests.  Also, this 
   project provides a .bat batch script that does this and
   provides a menu of other actions you can execute.

IntelliJ-IDEA

The required Gradle functionality is already built into IntelliJ-IDEA 12.1+ . I think using IDEA is more difficult but go ahead if you are familiar with it.

Notes

Website of this project:
http://djangofan.github.com/WebDriverTestingTemplate/

FAQ

1. If the intellisense in Eclipse doesn't work, make sure you 
   have added all the .class directories to your Eclipse project
   classpath.  (See the included .classpath file.)
2. I use "GitHub GUI" to sync my local project repo to GitHub. 
   If you fork my project, I would recommend doing it this way
   unless you are a Git expert and prefer another way.
3.