Using jquery with casperJs test

I have a web application that does not rely on jquery.

I perform functional tests thanks to (huge :)) casperjs.

Now I would like to use jquery in my tests. So I tried to enter it as indicated here http://casperjs.org/faq.html#faq-jquery . Well, that doesn't work.

Here is my code, if you can help me - is 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 deleted the test, as that is not the point ...

thanks!

+4
source share
1 answer

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

Also try setting absolute pass in jQuery script, e.g. /Users/foo/Work/project/tools/jquery-1.7.2.js .

+3
source

Source: https://habr.com/ru/post/1440110/


All Articles