Arquillian Drone provides a simple way to write functional tests for web apps. Drone brings the power of WebDriver into the Arquillian, and the power of Arquillian to WebDriver.
Java Other
Latest commit 90ae1c5 Feb 17, 2017 @MatousJobanek MatousJobanek From arquillian.xml removed predefined paths to webdrivers - it's not…
… necessary with automatic downloading
Permalink
Failed to load latest commit information.
.github Introduces templates for GH issues and PRs Oct 26, 2016
build-config [maven-release-plugin] prepare for next development iteration Jan 26, 2017
depchain ARQ-2060 Add support for Edge browser Feb 15, 2017
drone-api [maven-release-plugin] prepare for next development iteration Jan 26, 2017
drone-bom [maven-release-plugin] prepare for next development iteration Jan 26, 2017
drone-build [maven-release-plugin] prepare for next development iteration Jan 26, 2017
drone-configuration Adds new arquillian property to include command line args of Selenium… Feb 15, 2017
drone-impl [maven-release-plugin] prepare for next development iteration Jan 26, 2017
drone-spi [maven-release-plugin] prepare for next development iteration Jan 26, 2017
drone-webdriver From arquillian.xml removed predefined paths to webdrivers - it's not… Feb 17, 2017
extension [maven-release-plugin] prepare for next development iteration Jan 26, 2017
gradle/wrapper ARQ-2063 Upgraded build.gradle to use Spacelift 17 and Gradle 2.5 Dec 7, 2016
.gitignore Adding compatibility tests with Arquillian Core and Travis Oct 23, 2014
.travis.yml ARQ-2061 Upgraded to Selenium 3;removed support for deprecated seleni… Dec 7, 2016
README.adoc ARQ-2060 Add support for Edge browser Feb 15, 2017
build.gradle Updated arquillian-core to 1.1.12.Final Jan 3, 2017
gradlew Adding compatibility tests with Arquillian Core and Travis Oct 23, 2014
gradlew.bat Adding compatibility tests with Arquillian Core and Travis Oct 23, 2014
pom.xml [maven-release-plugin] prepare for next development iteration Jan 26, 2017

README.adoc

Arquillian Drone Build Status

The Arquillian Drone provides a simple way to write functional tests for an application with a web-based user interface. Arquillian Drone brings the power of WebDriver into the Arquillian framework. WebDriver provides a language how to communicate with a browser, like filling the forms, navigating on the pages and validating their content.

Why should I use Arquillian Drone instead of plain WebDriver?

There are many reasons why you want to do that, the most important being:

  • Life cycle management of the browser

  • Interaction with deployments and containers provided by Arquillian

  • Simple usage of multiple browsers in a single test

  • Configuration kept on a single place, outside of the Java code

  • Fully compatible with the IDE

  • Integration with mobile based browsers testing (Arquillian Droidium)

  • Integration of JavaScript test suite execution (Arquillian QUnit)

  • Compatible with WebDriver (Selenium 2) and Selenium Grids

If you are still not convinced that Arquillian Drone matches your needs, you might have a look at Arquillian Graphene 2, which is a wrapper on top of WebDriver, goes one step further and provides you a convenient way how to write tests for rich AJAX UIs with an ease, injections for Page Objects and Page Fragments and much more.

Getting Started

The following example illustrates how Arquillian Drone can be used with WebDriver:

@RunWith(Arquillian.class)
public class WebDriverTest {

    static final String USERNAME = "demo";
    static final String PASSWORD = "demo";

    @ArquillianResource
    URL contextPath;

    @Drone
    WebDriver driver;

    /**
     * Creates a testing WAR application
     *
     * @return WebArchive to be tested
     */
    @Deployment(testable = false)
    public static WebArchive createDeployment() {
        return Deployments.createDeployment();
    }

    @Test
    @InSequence(1)
    public void login() {
        LoginPage page = new LoginPage(driver, contextPath);
        page.login(USERNAME, PASSWORD);
    }

    @Test
    @InSequence(2)
    public void logout() {
        LoginPage page = new LoginPage(driver, contextPath);
        page.logout();
    }
}

You need to put following configuration to the pom.xml file of your project:

<dependencyManagement>
    <dependencies>
        <!-- Arquillian Core dependencies -->
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${version.org.jboss.arquillian}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- Arquillian Drone dependencies and WebDriver/Selenium dependencies -->
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-drone-bom</artifactId>
            <version>${version.org.jboss.arquillian.drone}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <!-- To use Arquillian Graphene (2) -->
    <dependency>
        <groupId>org.jboss.arquillian.graphene</groupId>
        <artifactId>graphene-webdriver</artifactId>
        <version>${version.org.jboss.arquillian.graphene2}</version>
        <type>pom</type>
        <scope>test</scope>
    </dependency>
</dependencies>
Note
You can use graphene-webdriver dependency chain even if you are willing to use plain WebDriver. Graphene will just bring you more goodies but it does not force you to change a single line of your code

Nevertheless, if you still don’t want to add the Graphene dependencies and just use the plain WebDriver, use this Drone dependency chain:

<dependencies>
    <dependency>
        <groupId>org.jboss.arquillian.extension</groupId>
        <artifactId>arquillian-drone-webdriver-depchain</artifactId>
        <version>${version.org.jboss.arquillian.drone}</version>
        <type>pom</type>
        <scope>test</scope>
    </dependency>
</dependencies>

Comprehensive Drone documentation can be found at https://docs.jboss.org/author/display/ARQ/Drone.

Automatic Download

Drone provides a functionality of automatic download of some binaries such as browser webdriver and Selenium Server jar. Which binaries and which features are supported can be found in tables below.

How it works?

Let say that I want to use Chrome for my UI tests. First of all, Drone checks if the path to the webdriver binary isn’t already set. In this case it would check a system property webdriver.chrome.driver; if this is empty then it checks arquillian.xml property: chromeDriverBinary. In case that both properties are empty, then the automatic download comes up.

Now we have several options how to specify which binary should be downloaded and where it should be stored. For storage purposes cache directories $HOME/.arquillian/drone/subdirectory_specific_to_binary are used so the binaries are not downloaded over and over again.

Version

Using a property

<property name="chromeDriverVersion">2.10</property>

you can define which version of the Chrome webdriver should be downloaded. The binary is then cached in a directory $HOME/.arquillian/drone/chrome/2.10/.

URL

Using a property

<property name="chromeDriverUrl">http://url/to/chrome/webdriver </property>

you can define which url the Chrome webdriver should be downloaded from. The directory where it is stored depends if you also specify the version of this binary or not. In case you use also the before-mentioned property chromeDriverVersion then it is cached in corresponding directory $HOME/.arquillian/drone/chrome/specified_version/; otherwise it is downloaded into $project.directory/target/drone/downloaded/ so no cache is used.

Latest

In case that you don’t define any property then Drone finds the latest version of the given binary and downloads this one. The binary (in case of Chrome webdriver) is cached at $HOME/.arquillian/drone/chrome/latest_version/.

Properties, directory names and support of latest versions

Selenium Server

System property

selenium.server.binary.path

arquillian.xml property

seleniumServerBinary

Latest version supported

yes

Version driver property

seleniumServerVersion

Url driver property

seleniumServerUrl

Cache subdirectory

selenium-server

Gecko driver (Firefox)

System property

webdriver.gecko.driver

arquillian.xml property

firefoxDriverBinary

Latest version supported

yes

Version driver property

firefoxDriverVersion

Url driver property

firefoxDriverUrl

Cache subdirectory

firefox

Chrome driver

System property

webdriver.chrome.driver

arquillian.xml property

chromeDriverBinary

Latest version supported

yes

Version driver property

chromeDriverVersion

Url driver property

chromeDriverUrl

Cache subdirectory

chrome

Edge driver

System property

webdriver.edge.driver

arquillian.xml property

edgeDriverBinary

Latest version supported

yes

Version driver property

edgeDriverVersion

Url driver property

edgeDriverUrl

Cache subdirectory

edge

IE driver

System property

webdriver.ie.driver

arquillian.xml property

ieDriverBinary

Latest version supported

yes

Version driver property

ieDriverVersion

Url driver property

ieDriverUrl

Cache subdirectory

internetExplorer

PhantomJS

System property

phantomjs.binary.path

arquillian.xml property

-

Latest version supported

no

Version driver property

-

Url driver property

-

Cache subdirectory

-

Opera driver

System property

webdriver.opera.driver

arquillian.xml property

operaDriverBinary

Latest version supported

no

Version driver property

operaDriverVersion (only in combination with url)

Url driver property

operaDriverUrl

Cache subdirectory

opera

Safari driver

System property

-

arquillian.xml property

-

Latest version supported

no

Version driver property

-

Url driver property

no

Cache subdirectory

-

Note:

We are not supporting Automatic downloading for safari & Download webdriver from a specific URL due to following reasons:

Automatic downloading for safari:

Starting with Safari 10 on OS X El Capitan and macOS Sierra, Safari comes bundled with a new driver implementation that’s maintained by the Web Developer Experience team at Apple. Safari’s driver is launchable via the /usr/bin/safaridriver executable, and most client libraries provided by Selenium will automatically launch the driver this way without further configuration. Safari-10

Download webdriver from a specific URL:

Starting with Selenium 2.48.0, you must manually install the SafariDriver browser extension. Refer getting started section from SafariDiver

Activate / Deactivate

The automatic download functionality is activated by default; if you want to set it off use the property:

<property name="downloadBinaries">false</property>

and no binary will be downloaded.

Building the project

Prerequisites:

  • JDK 8 and newer

  • Maven 3.0.3 and newer

Running test suite

You can use Arquillian Spacelift to gather all the required binaries. Just run:

./gradlew test

This will run tests using multiple Arquillian Core versions and phantomjs browser. In case you want to modify the behavior, you can specify -ParquillianCoreVersions=1.1.12 and -Pbrowser=phantomjs,firefox for instance. This will run integration test using a cross product of Arquillian Core and browsers defined.

Warning
Running testsuite this way will modify all pom.xml files in the project. Make sure you have committed all your changes there first.

Manual way to run test suite

Prerequisites:

  • running Selenium Server at port 4444, with paths to binaries required for remote browser execution. If you don’t do it by yourself, Drone will run an instance of Selenium Server automatically. However in this case the server is started and stopped for each test class separately and only in a standalone mode with only one parameter -port that is taken from defined remoteAddress.

    In case you want to specify other arguments to the selenium server, you can do so using the property,

    <property name="seleniumServerArgs">-debug -role hub -browserTimeout 1000</property>

    So, if you are fine with this automatic behavior you can skip this step, otherwise run your Selenium Server.

  • installed web browsers you want to test

  • you might want to align your layout to be the same as paths to binaries specified within arquillian.xml in drone-webdriver module. Alternatively, you can override properties with -Darq.extension.${extensionQualifier}.${propertyName}

Limitations:

  • reusable sessions are not supported by Edge browser therefore related tests are skipped

In order to start Selenium Server, execute:

java -Dphantomjs.binary.path=/path/to/phantomjs.binary -Dwebdriver.ie.driver=/path/to/iedriverserver.binary -jar selenium-server-standalone-3.0.1.jar

Once Selenium Server is running, you can run the tests by:

mvn clean verify -Dbrowser=${browser}

Where browser has the same value as browser property from arquillian.xml you want to tests (e.g. firefox, chrome, phantomjs, internetExplorer, opera, edge, etc.)

Tip
VNC server instance can be used to let all the browsers pop out in separate display. Just prepend both commands with DISPLAY=:${display.number}

Releasing new version

Run following commands:

mvn clean release:prepare release:perform

Make sure that you push the tag, close all issues with given version in JIRA and mark version as released.