Geb Browser Automation Quick Start for Continuous Integration Linux




How to Stand Up a Geb Sample Application On a CI Server(Continuous Integration) Linux


This guide will show you step-by-step how to setup a simple Geb app to get started using the automated testing framework.

This guide is intended for setting up automated browser tests on a Linux continuous integration server that is command line only with no UI enabled.

This guide focuses on using a headless browser for testing.


If you are trying to setup Geb on Windows instead please use the following link:

Setup Geb on Windows

Pull a copy of the Geb Sample App


 First, pull the Geb sample application from Github:

https://github.com/geb/geb-example-grails


HTTPS Clone URL:
https://github.com/geb/geb-example-grails.git



Add the GhostDriver library to your grails app


Add the following line to your BuildConfig.groovy:






5858
         // You usually only need one of these, but this project uses both
5959
         test "org.gebish:geb-spock:$gebVersion"
6060
         test "org.gebish:geb-junit4:$gebVersion"
61
62
         test( "com.github.detro.ghostdriver:phantomjsdriver:1.0.1" ) {
63
             transitive = false
64
         }
6165
     }
6266
 
6367
     plugins {

Update and sync your config and clean and rebuild your project.

Download Location for PhantomJS Ghostdriver


Find the download location for the most recent version here:  http://phantomjs.org/download.html


As of 4/21/2014 the most recent version is 1.9.7:


For 64-bit system, download phantomjs-1.9.7-linux-x86_64.tar.bz2 (12.6 MB).
For 32-bit system, download phantomjs-1.9.7-linux-i686.tar.bz2 (12.9 MB).

Install PhantomJS


Change directory to the location you want the driver.


Example:



cd home/bitnami

Retrieve the file


Example:


wget phantomjs-1.9.7-linux-i686.tar.bz2


Unzip the file


sudo tar -xjvf phantomjs-1.9.7-linux-i686.tar.bz2



Set the path in your GebConfig.groovy



1111
 
1212
 driver = {



15
14
     System.setProperty('phantomjs.binary.path', '/home/bitnami/phantomjs-1.9.7-linux-x86_64/bin/phantomjs')
1615
     new PhantomJSDriver(new DesiredCapabilities())
1716
 }
1817
 




Setup and Run your CI build

You will see something similar to this in your logs if it's successful

PhantomJS is launching GhostDriver...
[INFO  - 2014-04-21T14:42:34.840Z] GhostDriver - Main - running on port 9031
...
| Completed 1 spock test, 0 failed in 0m 44s
| Running 1 functional test...
| Running 1 functional test... 1 of 1
| Completed 1 functional test, 0 failed in 0m 35s
| Server stopped
| Tests PASSED - view reports in 
Finished: SUCCESS


You will be able to find the test reports in the following location


/project directory/target/test-reports



Additional Resources


Related links
PhantomJS
Geb Home Page
Geb Github
Book of Geb









Software Development Blogs - BlogCatalog Blog Directory

Popular posts from this blog

How to set up a SQL Server 2008 Local Database

Spring Boot Internationalization with Default Locale for Message Strings

Change Port on a Spring Boot Application when using intelliJ