我想用Codeception和PhantomJS来测试我的网页,除了一件恼人的事情之外,一切都很好。 WYSIWYG Redactor并未被PhantomJS加载,所有其他JavaScript都未被执行。我试图通过它创建仅主编一个非常简单的网页来隔离问题:WYSIWYG Redactor不能在PhantomJS工作
<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="redactor/redactor.js"></script>
<link rel="stylesheet" type="text/css" media="screen, projection" href="redactor/redactor.css">
<script>
$(function()
{
$('#redactor').redactor();
});
</script>
</head>
<body>
<textarea name="" id="redactor" cols="30" rows="10"></textarea>
</body>
</html>
然后,我有这个简单的测试脚本,我给PhantomJS:例如在
var page = require('webpage').create();
page.open('http://localhost/redactor/', function(status) {
console.log("Status: " + status);
if(status === "success") {
page.render('example.png');
}
phantom.exit();
});
结果。 PNG应该是简单的网页与主编加载,而是我PhantomJS错误:
TypeError: 'undefined' is not an object (evaluating 'tags.length')
http://localhost/redactor/redactor/redactor.js:6928
所以,我想通过把if(tags === undefined) return;
修复主编,但也有像3-4这些错误s,总是与undefined
问题。当我解决所有这些问题时,我只会在网页上找到textarea,但没有所见即所得。在浏览器中它的渲染效果很好(FF,Chrome,Opera,...),但在PhantomJS中它的bug。
我在做什么错?你们有没有遇到同样的问题?
您可以尝试更新到PhantomJS 2 – 2015-03-19 10:05:07