Kesäpäivänä Tuomiojärven rannalla Jyväskylän Viitaniemessä

Cucumber running Selenium on Debian Lenny

Julkaistu 18.08.2009 16:10.

I’ve been working with working with RSpec and Cucumber on Ruby on Rails for a while. I haven’t yet done any in browser testing but now I need to (need to automate a testsuite of non-RoR legacy webapp) and I like the idea of writing Cucumber scenarios for in browser tests too. I decided to give Selenium a try.

When I started my journey the instructions on Cucumber wiki were marked “outdated”. I’ll try to document what I needed to do and improve the wiki. This story applies to Debian Lenny, ruby 1.8.7 (2008-08-11 patchlevel 72) from Lenny packages, rubygems 1.3.1 from upstream source, rake 0.8.4 from gems and cucumber 0.3.96 from gems.

First I went to download Selenium remote control and unpacked the zip.

$ unzip

Package contained selenium client for ruby, but I decided to follow the recommendation in README and install from gems.

$ sudo gem install selenium-client

The moment of truth…

$ cd selenium-remote-control-1.0.1/selenium-server-1.0.1
$ java -jar selenium-server.jar

Selenium server was up and running. Then try to get some smoke out of Cucumber+Selenium examples.

$ cucumber /usr/lib/ruby/gems/1.8/gems/cucumber-0.3.96/examples/selenium/features/

Selenium server blew up complainig "ERROR - Failed to start new browser session, shutdown browser and clear all session data java.lang.IllegalArgumentException: URI "file:selenium-server.jar" is not hierarchical". Turned out it was about Java implementation. Talk about Java being cross-platform and stuff… Fine, easy one to fix.

$ sudo apt-get install sun-java6-jdk
$ sudo update-java-alternatives -s java-6-sun

Also Selenium server wanted to run Firefox binary (not the usual wrapper script) so I symlinked firefox-bin to /usr/local. The next complaint was

16:56:45.741 INFO - Preparing Firefox profile...
Could not read application.ini
16:57:05.757 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!

I spent quite a few hours trying to find out what was going on until I tried to run firefox-bin myself. It turned out that FF expects to find application.ini from the same dir the binary is in. On Linux there’s no direct way of finding out the path of the running binary. What FF does (if dirname(argv[0]) doesn’t work) is to manually walk thru $PATH. Path of the real binary wasn’t on $PATH (because I symlinked it there), FF couldn’t find application.ini and died.

Instead of symlink I just added FF dir (it’s the dir you have firefox-bin in, /usr/lib/iceweasel on Debian) to $PATH and it worked.