PhantomJs超时 [英] PhantomJs timeout

查看:159
本文介绍了PhantomJs超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jasmine和PhantomJS来运行测试用例。

I am using Jasmine with PhantomJS to run test cases.

在我的典型测试用例中,我进行服务调用,等待响应并确认响应。

In my typical test case, I make a service call, wait for response and confirm response.

有些请求可以在几秒钟内返回,有些请求可能需要一分钟才能返回。

Some requests can return in a few seconds and some can take up to a minute to return.

PhantomJS,测试用例因服务调用失败而应该花费一分钟(因为尚未收到响应而失败)。

When ran through PhantomJS, the test case fails for the service call that is supposed to take a minute ( fails because the response is not yet received).

有趣的是测试通过当通过Firefox运行时。

What's interesting is that the test passes when ran through Firefox.

我已经尝试查看tcpdump,并且两个浏览器的请求标题相同,所以这看起来像浏览器超时问题。

I have tried looking at tcpdump and the headers are same for requests through both browsers, so this looks like a browser timeout issue.

有没有人有类似的问题?关于何时可以配置超时的任何想法?或者你认为问题是别的什么?

Has anyone had a similar issue ? Any ideas as to where could the timeout be configured ? Or do you think the problem is something else ?

推荐答案

我有完全相同的问题。您所要做的就是添加setTimeout以退出

I had exactly same issue. All you have to do is add setTimeout to exit

 setTimeout(function() {phantom.exit();},20000); // stop after 20 sec ( add this before you request your webpage )

 page.open('your url here', function (status) {
  // operations here
 });

这篇关于PhantomJs超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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