Geb Quickie: Automatically download drivers for Chrome and Internet Explorer

A common error encountered by Geb beginners using Webdriver with Chrome or Internet Explorer is that they forget to download and properly configure chromedriver / iedriver.

In this post, I will show you how to set up your project so that it ensures that your driver file is available for your tests. ( Credit Marcin Erdmann for initial implementation ).

Continue reading

Grails 2.x update gotcha – your logging has changed

When updating your application to grails 2.x from the 1.3.x branches, you might notice that your logging no longer works.

This is due to changes in the logging by convention. While this is mentioned in the user guide (under Logging By Convention Changes), it is not very clear what this means.

In our update, we found that we needed to change our Log4J configuration from:

 info 'grails.app.controller',
      'grails.app.task',
      'grails.app.service',
      'grails.app.tagLib',
      'grails.app.bootstrap.BootStrap'

to:

info 'grails.app.controllers',
     'grails.app.jobs',
     'grails.app.services',
     'grails.app.taglib',
     'grails.app.conf.BootStrap'

While this might look trivial, it’s a fairly important breaking change.

Additionally, if you have Quartz jobs in your application, the logging convention changes from task to jobs. This is not mentioned in the grails documentation.

Happy upgrading.

Getting grails wrapper to work with grails 2.1.2

There is currently a bug in Grails 2.1.2 that breaks the grails wrapper functionality. ( GRAILS-9646 )

To work around this bug in all computers, you can get the grails wrapper to download a patched version of the grails 2.1.2 zip file. There is a fixed version of this zip file here: http://grails212.cloudfoundry.com/grails-2.1.2.zip

To use it, install the wrapper via the ‘grails wrapper’ command. Then, edit your wrapper/grails-wrapper.properties file to:

wrapper.dist.url=http://grails212.cloudfoundry.com/

To prepare your own patched file,

  • Download grails 2.1.2.
  • In the zip file, remove the source and docs jar files under grails-2.1.2\lib\org.codehaus.groovy\groovy-all\jars\
  • Save the zip file.
  • Upload the new zip file to a location accessible to the web.

This bug has already been fixed in grails core. But if you need to use the grails wrapper in the meantime, just use this mechanism.

A subtle difference between closures and .& closures in groovy

We were trying to sort out a weird issue we were having in Grails today, and came across a subtle difference in the way groovy deals with closures and closures that are transformed from methods.

In short, when you convert a method into a closure via .&, the references inside the method don’t get converted and you end up with unexpected results.
Continue reading

Geb and Sikuli – Adding image recognition to help your functional tests see

One of the drawbacks with testing with Webdriver is that it offers very little in terms of validating things visually. Webdriver also has very limited interaction with alerts, the desktop and embedded components such as Flash, Java or Browser plugins.

When you have a QA person, they will be able to immediately check that an image is too big, or that the responsive design is broken a certain screen size. The vocabulary of XPaths and DOM elements is sometimes too limited to capture what a human sees.

Webdriver can simulate the user interacting with the browser with a mouse and keyboard, but not what this user is able to perceive.

In this post, I would describe my experiment marrying the Sikuli image recognition framework with the geb testing framework. It will describe how we can use some of the features in Sikuli to expand our functional tests and even overcome some limitations within the very powerful webdriver / geb combination.

Continue reading