unludo
unludo

Reputation: 5016

Using jquery with casperJs test

I have a web application which is not relying on jquery.

I am doing functional tests thanks to (the great :) ) casperjs.

Now I would like to use jquery in my tests. So I tried to inject it as indicated here http://casperjs.org/faq.html#faq-jquery. Well, it's not working.

Here is my code if you can help me - is there something wrong? :

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

I removed the test as it is not the point...

thanks!

Upvotes: 4

Views: 6504

Answers (1)

NiKo
NiKo

Reputation: 11411

Try to add casper.options.clientScripts = ["../tools/jquery-1.7.2.js"] at the top of your test script.

Also try to set the absolute pass to the jQuery script, eg. /Users/foo/Work/project/tools/jquery-1.7.2.js.

Upvotes: 3

Related Questions