History: PluginCasperJS
Source of version: 8
Copy to clipboard
! {{page}} New to ((Tiki17)). This new ((wiki plugin)) allows to use "CasperJS" in Tiki, which is a navigation scripting & testing utility for PhantomJS and SlimerJS (still experimental). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks. See more information at ((PhantomJS and CasperJS)) Code is here: https://sourceforge.net/p/tikiwiki/code/HEAD/tree/trunk/lib/wiki-plugins/wikiplugin_casperjs.php __How to use the code:__ * Enable casper (pref wikiplugin_casperjs ) * Create a tiki page with the following content: {CODE()} {CASPERJS()} {SOURCE()} var casper = require('casper').create(); var links; function getLinks() { // Scrape the links from top-right nav of the website var links = document.querySelectorAll('ul.navigation li a'); return Array.prototype.map.call(links, function (e) { return e.getAttribute('href') }); } // Opens casperjs homepage casper.start('http://casperjs.org/'); casper.then(function () { links = this.evaluate(getLinks); tikiBridge.add('links', links); }); {SOURCE} {CASPERJS} {CODE} * Run it :-) __What works__ Currently, it runs casperjs, and display back to the user: * The (full) script that was run * The output of the command line * The results from the casperjs execution, using TikiBridge (is injected into the CasperJS script as a easy way to send results back to tiki). How does the TikiBridge works: * Before running the script it prefix and postfix the CasperJS script with some JS code (the TikiBridge) * You can send variables back to Tiki by calling -+TikiBridge.add('variable_name', variable)+- * At the end of the script (is appended) a call to -+TikiBridge.done+- that will format the variables to be sent back to tiki. __Next Steps__ * Discuss specific implementations to see how to use this data and what is needed to make it useful to a tiki instance. * Make some ((profiles))