我潜入功能测试,并试图获得工作的几个简单的任务。该应用程序内置在ReactJS中,我决定使用Phantom/Casper。问题是即使是最基本的任务也会失败。测试应用程序作出反应与幻影/卡斯帕
总之,有一个用于测试的伎俩反应与幻影/卡斯帕应用程序?
我已经安装了幻影(2.1.1版)和卡斯帕(V1.1.0-β5)。作为第一次尝试我创建了一个简单的脚本来捕捉图像:
capture.js
var casper = require('casper').create({
viewportSize: {
width: 1024,
height: 768
},
verbose: true,
logLevel: "debug"
});
casper.start('http://localhost:9494', function() {
console.log("page loaded");
});
casper.then(function() {
this.capture('img.png');
});
});
casper.run();
然后运行该脚本:在浏览器中拉
> casperjs capture.js
查看localhost:9494
的应用程序应该如此。但由此产生的capture()
图像是一个空白屏幕。
我也尝试添加一个wait()
,waitForSelector()
和waitForResource()
无济于事。
下面是在控制台输出:
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: http://localhost:9494/, HTTP GET
[debug] [phantom] Navigation requested: url=http://localhost:9494/, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "http://localhost:9494/"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/2 http://localhost:9494/ (HTTP 200) page loaded
[debug] [phantom] Capturing page to /path/to/img.png
[info] [phantom] Capture saved to /path/to/img.png
[info] [phantom] Step anonymous 2/2: done in 848ms.
[info] [phantom] Done 2 steps in 848ms
[debug] [phantom] Navigation requested: url=about:blank, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "about:blank"
运行到同样的问题。一个正常的网页会很好,只是反应的应用程序不加载 – Boyang