Multiple sessions are not often needed when writing Cucumber scenarios. Normally to validate that a user can or can not see what another user created you would simply sign in as another user. However, this is not the case when you use WebSockets to deliver information in real-time. If you were to sign in as another user there would be no record of the previous events.
While searching for a solution I found Cucumber Testing for Multiple Users by Bernard Potocki. He shows how to achieve multiple sessions with Cucumber and Selenium, but I wanted to make it easier.
Drop the following into cucumber/support/sessions.rb.
Now you can write step definitions such as:
Which allows for scenarios to deal with multiple sessions.
Conclusion & Example
It’s very comforting knowing that I can test interactions between two users now. And while I have not tried it yet, you can potentially test interactions between a group of users.