在构建过程中,我使用casperjs和phantomjs运行JS e2e测试。更新到最新版本(phantomjs-prebuilt:2.1.12,casperjs:1.1.3)后,当我尝试填写表单时出现以下错误:
FAIL Unable to fill form: TypeError: Function.caller used to retrieve strict caller
type: uncaughtError
file: tests/js/e2e/dummyTest.js:815
error: Unable to fill form: TypeError: Function.caller used to retrieve strict caller
fillForm@phantomjs://platform/casper.js:815:79
fillSelectors@phantomjs://platform/casper.js:912:25
phantomjs://code/dummyTest.js:170:27
runStep@phantomjs://platform/casper.js:1615:31
checkStep@phantomjs://platform/casper.js:406:28
stack: not provided
以下是测试代码的简单示例:
casper.test.begin("Dummy test", function suite(test) {
casper.start('http://www.heureka.cz/', function() {
casper.echo('Page loaded: ' + this.getTitle());
this.fillForm('form#f_search', { // same effect/problem with fill method
'h[fraze]': 'test'
});
});
casper.run(function() {
test.done();
});
});
我发现错误是由casperjs中的clientutils.js:691
中的此函数引起的:
this.log = function log(message, level) {
console.log("[casper:" + (level || "debug") + "] " + message);
};
使用phantomjs v1.9.20一切正常。