Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript phantomjs和run-jasmine.js超时_Javascript_Unit Testing_Jasmine_Phantomjs - Fatal编程技术网

Javascript phantomjs和run-jasmine.js超时

Javascript phantomjs和run-jasmine.js超时,javascript,unit-testing,jasmine,phantomjs,Javascript,Unit Testing,Jasmine,Phantomjs,所以我有一个奇怪的问题 我有一个Jasmine测试运行程序在我的机器上本地运行,可以在localhost:8080/test/runner.html上找到 当我在网络浏览器中打开它时,它工作得非常好 我想自动化这一点,所以我使用phantomjs(从brew安装——我在mac上)并使用代码中的示例run-jasmine.js文件 但是,每当我针对URL运行它时,我都会得到以下结果: phantomjs war/test/spec/run_jasmine.js http://localhost:8

所以我有一个奇怪的问题

我有一个Jasmine测试运行程序在我的机器上本地运行,可以在localhost:8080/test/runner.html上找到

当我在网络浏览器中打开它时,它工作得非常好

我想自动化这一点,所以我使用phantomjs(从brew安装——我在mac上)并使用代码中的示例run-jasmine.js文件

但是,每当我针对URL运行它时,我都会得到以下结果:

phantomjs war/test/spec/run_jasmine.js http://localhost:8080/test/runner.html
'waitFor()' timeout
所以我写了一个非常简单的脚本,看看我是否遗漏了什么:

var page = require('webpage').create();

page.open(phantom.args[0],
function(status) {
    if (status !== "success") {
        console.log("Unable to access network");
        phantom.exit();
    } else {
        if (document.body.querySelector('#hello')) {
            console.log('hi');
        }
    }
});
并创建了一个新的HTML文件:

<!DOCTYPE html>
<html>
<head>
    <title>hi</title>
</head>
<body>
    <div id="hi"></div>
</body>
</html>

你好
而这东西仍然永远挂着

我是不是遗漏了什么?我知道页面正在加载,但它看起来不像phantomjs在解析它。

我觉得自己很笨


/test/需要身份验证。

这听起来可能有点傻,但是如果用127.0.0.1替换localhost?有什么不同吗?这并不愚蠢,但遗憾的是这不起作用。但是让我思考——如果我尝试telnet到端口8080,然后执行一个
GET/test/runner.html HTTP/1.1
,会发生什么。很低,请注意-
HTTP/1.1400错误的请求连接:关闭服务器:Jetty(6.1.x)
服务器出现问题。。。(这是盖伊的本地服务器)噢,该死的。服务器正在弹出请求登录凭据的页面。我现在得把它编码到这里面。和处理饼干。或者只是移动到另一个子目录…哈哈,我在用我们的.net解决方案实现phantomjs时犯了完全相同的错误。这就是我们学习的方式!还有一个是因为觉得自己很笨:)