如何测试聊天网络应用 [英] How to test chat web app

查看:141
本文介绍了如何测试聊天网络应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用服务器上的node.js socket.io模块和客户端上的javascript开发聊天应用程序。随着变得越来越复杂,我厌倦了通过跨浏览器单击来测试不同的使用方案。现在,我使用不同的浏览器来分隔cookie。因此,在Firefox中,有一个聊天参与者,在Opera中是第二个聊天参与者,等等。

I am developing chat application, using node.js socket.io module on a server, and javascript on a client. As it become more complex, I become tired to test different usage scenarios by clicking across browsers. At now I use different browsers in order to separate cookies. So in Firefox there is one chat participant, in Opera - second, etc.

因此,我的问题是:

我能以某种方式使它自动化吗?

我听说过无头测试引擎,例如Phantom JS,Selenium WebDriver,但我不知道如何在不同的浏览器之间编写测试。实际上,我确实需要分离cookie,不同的浏览器仅在此处用于此任务。

I've heard about headless testing engines like Phantom JS, Selenium WebDriver, but I don't know how to write tests between different browsers. In fact, I indeed need to separate cookies, different browsers are here only for this task.

也许我无法向Google解释我的问题:)

May be I cannot explain my problem to Google :) All answers on such question imply cross-browser development, and testing that aspect.

任何帮助将不胜感激!

推荐答案

如何测试两个交互的浏览器(例如聊天应用程序)中显示的答案可能是如果您尝试使用Casper / Phantom / SlimerJS路线,请使用此功能。我不会将其标记为重复项,因为您的问题较为笼统,而该问题恰恰是关于如何同步两个CasperJS实例;

The answers shown at How to test two interacting browsers (e.g. chat app) might be of use if you try to go the Casper/Phantom/SlimerJS route. I'm not marking it as a duplicate as your question is more general, whereas that one is about exactly how to synchronize two CasperJS instances; it is also not specifically about socket.io.

注意:如果使用Phantom测试Web套接字,则需要获得Phantom 2.x(仍处于试验阶段,并且还没有可轻松下载的Beta版,因为Phantom 1.x使用的是旧版WebKit。 SlimerJs始终使用最新的Gecko(即Firefox)引擎,所以很好。

Note: if using Phantom to test Web Sockets you will need to get Phantom 2.x (which is still experimental, and does not have an easily downloadable beta yet), as Phantom 1.x uses an old WebKit. SlimerJs always uses a recent Gecko (i.e. Firefox) engine, so is fine.

每个PhantomJS实例都可以拥有自己的cookie。 此答案(以及该问题的其他答案)很好地说明了您的选择。

Each instance of PhantomJS can have its own cookies. This answer (and the other answer on that question) explains your choices well.

SlimerJS cookie 相似,但是持久性cookie存储在Mozilla配置文件,因此,如果要运行多个实例,则需要为每个实例指定一个明确的配置文件。 (尽管您的聊天应用程序可能仅使用会话cookie,在这种情况下这无关紧要。)

SlimerJS cookies are similar, but persistent cookies are stored in the Mozilla profile, so if you wanted to run multiple instances, you would want to specify an explicit profile for each instance. (Though your chat application may only be using session cookies, in which case this does not matter.)

无论如何,由于使用了cookie,我肯定会运行两个CasperJS实例,而不是尝试使用两个标签或两个框架。

Anyway, as cookies are used I would definitely run two instances of CasperJS, rather than try to use two tabs, or two frames.

这篇关于如何测试聊天网络应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆