2009-10-14

Maven, Selenium and a hint of Groovy

Leonard Axelsson | fix, groovy, mac, maven, selenium, snowleopard

Getting selenium running on maven using selenium-rc and tests written in groovy is a piece of cake, well at least when someone else has written the tutorial already: Grails, Selenium, Maven and integration testing

The only thing I found lacking for my use case was nice html reports. Those can can be added using the maven-surefire-report-plugin.

Add this to mavens pom.xml:

<project>
...

<reporting>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-report-plugin</artifactId>
      <version>2.4.2</version>
    </plugin>
  </plugins>
</reporting>

...
</project>

 

Everything works now right?

Well yeah, as long as you aren't on a Mac upgraded to Snow Leopard. Basically there is a problem with Firefox and Snow Leopard which makes Selenium crash. After some googling I found this post, mentioning among other things a fix to our problem (step 4).

This solved the problem for me (copy into the terminal):

# Make a backup of the old file
mv /Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib \\
/Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib.orig

# Copy in the working file
cp /usr/lib/libsqlite3.dylib \\
/Applications/Firefox.app/Contents/MacOS/libsqlite3.dylib

 

Show me the code!

All you really need is maven and the pom. To make it all as simple as possible I've put a complete demo up on github, modify it to suit your needs. I used groovy to write the selenium tests but java should work as well.

Share

Whats your thoughts on the matter? Comments below and trackbacks here

2009-10-14 21:10

TipTrick

Hello, nice post. I have a question, is there a way to do code coverage on groovy code ... ?


2009-10-14 22:11

mike

Yes, you can use Cobertura (http://cobertura.sourceforge.net/) to do coverage on Groovy code. If you're using Grails, you can even use the Code-Coverage plugin (http://grails.org/plugin/code-coverage) to do it


2009-10-14 23:24

Leonard

Thanks. As Mike said you can use cobertura to generate a cove-coverage report for your Groovy based tests. If you're using maven it's as easy as adding the following to your poms build plugins. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> </plugin>


2009-10-14 23:26

Leonard

Sorry about the bad formatting, we really need to look into how comments are handled on the blog. You can read more about using the Cobertura maven-plugin here: http://mojo.codehaus.org/cobertura-maven-plugin/


2009-10-15 09:56

TipTrick

Thanks, now I have basic code coverage support. But have a problem if I want to see lines which are (not)covered, after click on source file link gives me a message "Unable to locate xxx.groovy. Have you specified the source directory?".


2009-10-16 14:42

Leonard

I went back to check my old code and couldnt find any working examples of using maven with cobertura for groovy-code, I'll have to get back to you on that one.


2009-10-17 12:20

webpatser

I wrote a simple howto for Snow Leopard and selenium using firefox 3.5. You can find it here http://www.god-object.com/2009/10/16/user-interface-testing-on-mac-os-10-6-snow-leopard/


2009-11-03 09:36

Leonard

Thanks for the tip webpatser!



Name:

Comment:


Captcha:

Enter captcha below:



Subscribe to RSS Feed
Home
About
Work at QBRANCH
Mac Rumors
Qi4j
Kim Cameron's Identity Weblog
The Java Posse
Grails
DSCT
Qanban
.net ASP.NET CMS ESI Escenic FAST QbranchSyd Sharepoint TIOBE VCL ad adfs agent amazon amazonwebservices announcement api appengine applicationmanagment appservers aspx authentication aws blog c# cache cassatt challenge chrome cloud cloudcomputing cmis code conference convert csv ddd denmark dependecyinjection designpatterns development dsl ec2 eclipse ecm eucalyptus example export fix gaelyk google gps gr8conf grails griffon groovy ilm interview inthecode invitation iphone java javascript jazz jfokus jmx kanban licensing linux load times mac mailinglist maps maven meeting microsoft midp mvp opensource optimization outsourcing plugins postback presentation privatecloud project qanban qbranch rekrytering rest rmi robot s3 saml scala schedule scripting scriptoftheweek selenium snowleopard soa soap sourcing springsource spy sql sso sweden swegug terracotta test text tomcat trace twitter update url usergroup varnish visualstudio webbrowser webkit webservice windowsserver wired wpf