Cucumber/Webrat/Selenium + SSL?


#1

Has anybody had any luck getting Cucumber, Webrat and Selenium to play
nicely together for SSL sites?

My test environment:

  • nginx front-end accepting SSL requests, proxying them to mongrel
    back-end

  • mongrel back-end accepting normal HTTP requests

  • application routes configured with “:protocol => ‘https’” so that
    URLs generated with “_url” helpers will be SSL ones

  • application links basically all generated using “_path” helpers and
    not “_url” helpers, so the site can be tested by connected directly to
    the mongrel instance rather than having to go through the nginx proxy

  • Cucumber paths (in “features/support/paths.rb” defined using “_path”
    helpers, not “_url” helpers)

The problem is that when I try to run my features through Selenium
following the instructions here:

http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium

Selenium starts up and tries to access the site using HTTPS. This in
turn throws up a warning dialog about the self-signed certificate
(evidently a certificate for “localhost” can only ever be self-signed)
which prevents the suite from running. You can go into the Firefox
preferences and add an exception for the “localhost” domain but it
won’t persist because every time you run the suite Selenium launches a
clean copy of Firefox with a blank profile.

This page provides some tips on how to set up a Firefox profile
containing the exception and force Selenium to use it:

http://blog.thirstybear.co.uk/2008/05/selenium-and-https.html

But that won’t work when using Cucumber/Webrat, because as far as I
can tell from the Webrat Selenium docs.

http://github.com/brynary/webrat/blob/master/lib/webrat/selenium.rb

Webrat will “automatically start the Selenium Java server process and
an instance of Mongrel when a test is run”. So there is no way that I
can see to force Webrat to launch the Selenium server process with the
custom Firefox profile.

So I guess there are two possible options here: either find a way to
make Webrat use the custom profile (most likely by hacking the code
directly), or find a way to make Selenium connect to the Mongrel
directly (via HTTP) instead of the nginx instance (via HTTPS). Not
really sure how I would go about that one really, seeing as in my
“features/support/paths.rb” file I am obviously specifying paths (no
host specification) anyway.

Has anyone had any success getting this to work? Until I can find a
solution it basically means that all of the JavaScript/AJAX stuff in
the app has no automated testing at all. I suppose I could dump Webrat
and speak directly to Selenium, as demonstrated in the example:

http://github.com/aslakhellesoy/cucumber/tree/master/examples/
selenium

But, then I’ll have a nasty division in my features between those that
can use Webrat and those which can’t. Any solutions?

Cheers,
Wincent


#2

On Apr 29, 6:04 am, Wincent C. removed_email_address@domain.invalid wrote:

Webrat will “automatically start the Selenium Java server process and
an instance of Mongrel when a test is run”. So there is no way that I
can see to force Webrat to launch the Selenium server process with the
custom Firefox profile.

You can tell webrat to not launch Selenium RC and to instead connect
to an already running instance by setting the selenium_server_address
configuration variable. It’s not well documented (it was originally
added to support Selenium Grid) and is perhaps not an ideal solution
to the problem you face, but it might be preferable to monkey-patching
webrat.