Javascript 在casperJs测试中使用jquery
我有一个不依赖jquery的web应用程序 感谢(伟大的:)casperjs,我正在做功能测试 现在我想在测试中使用jquery。所以我试着按这里的说明注射它。嗯,它不起作用了 这是我的代码,如果你能帮我-有什么问题吗Javascript 在casperJs测试中使用jquery,javascript,unit-testing,phantomjs,casperjs,Javascript,Unit Testing,Phantomjs,Casperjs,我有一个不依赖jquery的web应用程序 感谢(伟大的:)casperjs,我正在做功能测试 现在我想在测试中使用jquery。所以我试着按这里的说明注射它。嗯,它不起作用了 这是我的代码,如果你能帮我-有什么问题吗 casper.start('http://localhost:8080/xxxxxx/xxxxxDialogTests.html'); casper.echo("page = " + casper.page); // -> it works, the page is th
casper.start('http://localhost:8080/xxxxxx/xxxxxDialogTests.html');
casper.echo("page = " + casper.page); // -> it works, the page is there
casper.page.injectJs("../tools/jquery-1.7.2.js");
casper.waitFor(function check()
{
return this.visible('#button_create');
},
function then()
{
this.click('#button_create');
casper.waitFor(function check()
{
return this.visible('#dialog_document_name');
},
function then()
{
console.log("element : ", this.evaluate(function ()
{
var el = $("input#dialog_document_name");
return el;
}));
});
});
我删除了测试,因为它不是重点
谢谢 尝试在测试脚本顶部添加
casper.options.clientScripts=[”./tools/jquery-1.7.2.js“]
还要尝试设置jQuery脚本的绝对传递,例如,
/Users/foo/Work/project/tools/jQuery-1.7.2.js
路径是否绝对正确?您是否收到任何错误消息?是的,我可以看到指定文件夹中的文件,并且没有任何错误。只有控制台日志返回“element:null”