phantomjs 和 run-jasmine.js 超时

发布于 2025-01-07 11:43:08 字数 1038 浏览 3 评论 0原文

所以我有一个奇怪的问题。

我在我的机器上本地运行了一个 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 看起来并没有解析它。

So I've got an odd issue.

I've got a Jasmine test runner running locally on my machine available at localhost:8080/test/runner.html

When I open it in a web browser it works perfectly.

I wanted to automate this so I'm using phantomjs (installed from brew -- I'm on a mac) and I'm using the example run-jasmine.js file from the code.

But, whenever I run it against the URL, I get this:

phantomjs war/test/spec/run_jasmine.js http://localhost:8080/test/runner.html
'waitFor()' timeout

So I wrote a really simple script to see if there is something I'm missing:

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');
        }
    }
});

And created a new HTML file:

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

And the thing still just hangs forever.

Am I missing something here? I know the page is being loaded, but it doesn't look like phantomjs is ever parsing it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤星 2025-01-14 11:43:08

好吧,我觉得很愚蠢。

/test/ 需要身份验证。

Well I feel dumb.

The /test/ requires authentication.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文