views:

32

answers:

1

I'm fixing up some old integration tests for our (RoR 2.3.5) website, and some scenarios (and their behaviors) depend on having multiple users logged in simultaneously. Once upon a time, these worked... three engineers and 18 months ago.

Our basic scenarios are written in cucumber, with capybara binding to selenium. I've tried all of the variations on Capybara::Session.new and open_session that I can imagine. These either programatically succeed, but continue to use the existing selenium window; or, they result in some testing method not existing.

I've also tried using webrat for the "secondary" sessions, but can't convince cucumber to switch drivers for a single step in a scenario (although it does switch between scenarios).

Am I totally up the proverbial creek? What would be awesome is for selenium to open multiple browsers as multiple unix users so that they don't share session state, and then log into the website. But, I have no idea where I'd even look to start hacking on that.

Honestly, at this point, I don't even know what tools I'm using, and which is responsible for what feature. Diving into the code of capybara and cucumber yields hundreds of lines of metaprogramming magic that somehow accretes into a testing framework. It's really making me loathe TDD despite my previous youthful enthusiasm.

+1  A: 

Try upgrading to 0.4.0.rc. Selenium allows multiple sesssions now (which will start multiple browsers, just so you know). There's still no high-level API for it though, so you have to manually instantiate a session and work with that.

jnicklas
Wow, the man himself. How, may I ask, do I actually get ahold of the selenium session to create a new one? I'm totally flummoxed.
Aubrey Jones
Something like `Capybara::Session.new(:selenium, MyRackApp)`. If you're otherwise using the DSL then `Capybara::Session.new(:selenium, Capybara.app)` should do the trick. note that you then need to call whatever it is you want on that returned session object. See the README for more details.
jnicklas