我试图在我的测试中注入jQuery但是我收到以下错误:
ReferenceError:找不到变量:$
它是一个ruby on rails应用程序,我正在尝试测试,在WEBrick上运行.这是所有代码:
var casper = require('casper').create({
clientScripts: ['jquery-1.9.1.min.js']
});
//make sure page loads
casper.start('http://127.0.0.1:3000', function() {
this.test.assertTitle('EZpub', 'EZpub not loaded');
});
//make sure all 3 fridges are displayed
casper.then(function() {
//get fridges
var fridges = $('a[href^="/fridges/"]');
this.test.assert(fridges.length == 3, 'More or less than 3 fridge links shown');
});
casper.run(function() {
this.echo('Tests complete');
});
Run Code Online (Sandbox Code Playgroud) 我想用'好'类来计算div元素的数量.我有选择器div.nice,但不知道使用哪个casperjs类/方法.
实际上有一个tester.assertElementCount方法,但是有什么东西可以简单地返回元素的数量吗?