Testing multiple concurrent browser sessions

I am developing a card game in Ruby on Rails and trying to figure out how best to test it.

When a player joins the game, their Player object is saved in the session. Obviously, for the game to work, I need more than one player in the game at once. Since sessions are the same for different tabs in the same browser, I am currently testing a two-player game by opening the application in FireFox and Internet Explorer at the same time.

Before I leave and download Chrome to check out the third player ... is there an easier way to do this?

Edit: To clarify, I'm still not at the point where I want to run automated tests to see if it breaks. I am at the stage when I want to be able to hack back-end db, and then refresh the page and see how it looks now, or press a button to see the answer (usually) about the refusal or the behavior to the right.

+6
browser ruby-on-rails session testing
source share
4 answers

You can run Firefox with multiple profiles. From the command line, change to the directory in which Firefox is installed and firefox -P launched. Create a profile for each instance that you want to run. Close the profile manager, then for each profile run firefox -no-remote -P "profile name" . You can run as many instances of Firefox as possible, and each of them works with an independent profile and, therefore, an independent session.

+5
source share

Automate it!


You really do not want this to be manual. You can use the Ruby script with curl libs to generate "moves" and control the response, including the session cookie.
As a teaser, see this snippet from the API docs, it seems like this will help you ..

 easy.cookiejar = "cookiejar.file" => "pwd string" Set a cookiejar file to use for this Curl::Easy instance. This file will be used to persist cookies. 
+1
source share

Use http://watir.com/ to create ruby ​​scripts that run your game.

Use multiple instances of Watir::Browser to launch multiple browsers.

Use firefox and -no-remote profiles to separate them. See also this question .

+1
source share

Instead of opening a new tab, create a new window in your web browser. The new window will have its own session. This works for Internet Explorer, but not for Firefox. I have not tested it in WebKit-based browsers.

0
source share

All Articles