4

jqueryに依存しないWebアプリケーションがあります。

私は(素晴らしい:))casperjsのおかげで機能テストを行っています。

ここで、テストでjqueryを使用したいと思います。そこで、ここhttp://casperjs.org/faq.html#faq-jqueryに示されているように注入しようとしました。まあ、それは機能していません。

あなたが私を助けることができるなら、これが私のコードです-何か問題がありますか?:

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;
           }));  
   });
});

それがポイントではないので、私はテストを削除しました...

ありがとう!

4

1 に答える 1

3

casper.options.clientScripts = ["../tools/jquery-1.7.2.js"]テストスクリプトの先頭に追加してみてください。

また、絶対パスを jQuery スクリプトに設定してみてください。/Users/foo/Work/project/tools/jquery-1.7.2.js.

于 2012-10-18T06:28:38.850 に答える