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
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:
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:
But that won’t work when using Cucumber/Webrat, because as far as I
can tell from the Webrat Selenium docs.
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
the app has no automated testing at all. I suppose I could dump Webrat
and speak directly to Selenium, as demonstrated in the example:
But, then I’ll have a nasty division in my features between those that
can use Webrat and those which can’t. Any solutions?