4

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!

2
  • Is the path ../ definitely correct? Are you getting any error message at all? Commented Oct 16, 2012 at 18:12
  • Yes I can see the file in the folder indicated and there is no error at all. Just the console log is returning 'element : null' Commented Oct 16, 2012 at 18:15

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.