开发者

Testing multiple concurrent browser sessions

开发者 https://www.devze.com 2022-12-20 05:42 出处:网络
I\'m developing a card-game in Ruby on Rails, and trying to work out how best to test it. When a player joins a game, their Player object is stored in the session. Obviously, in order for the game t

I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it.

When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing a 2-player game by having the app open in FireFox and Internet Explorer at the same time.

Before I go off and download Chrome in order to test a third player... is there an easier way of doing this?

Edit: To clarify, I'm not yet at the stage where I want to run automated t开发者_如何学Cests to see if it breaks. I'm at the stage where I want to be able to hack the back-end db, then refresh the page and see how it looks now, or click a button to see the (usually) failure response, or whether the behaviour is looking right.


You can run Firefox with multiple profiles. From a command line go to the directory Firefox is installed in and run firefox -P. Create a profile for every 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 you want, and each one runs with an independent profile and thus independent session.


Automate it!


You really don't want to be manually testing this. You could use a Ruby script with the curl libs to generate the 'moves' and manage the response including the session cookie.
As a teaser, see this snippet from the API docs, sounds like it would 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. 


Use http://watir.com/ to create ruby scripts exercising your game.

Use multiple Watir::Browser instances to run multiple browsers.

Use firefox' profiles and -no-remote switch to keep them separated. See also this question.


Rather than 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 haven't tested it in the WebKit based browsers.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号