Loading...
 
Skip to main content

History: PhantomJS and CasperJS

Source of version: 10

Copy to clipboard
            {QUOTE()}CasperJS 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 such as:

    defining & ordering navigation steps
    filling forms
    clicking links
    capturing screenshots of a page (or an area)
    making assertions on remote DOM
    logging & events
    downloading resources, even binary ones
    catching errors and react accordingly
    writing functional test suites, exporting results as JUnit XML (xUnit)
{QUOTE}

{QUOTE()}
PhantomJS is a headless WebKit with JavaScript API. It has fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

PhantomJS is an optimal solution for fast headless testing, site scraping, pages capture, SVG renderer, network monitoring and many other use cases.
{QUOTE}


!! How to install CasperJS and PhantomJS for Tiki

Step 1)

Add, in the composer.json, the following lines to "post-install-cmd" and "post-update-cmd" of the "scripts" section:

{CODE()}
"PhantomInstaller\\Installer::installPhantomJS",
"CasperJsInstaller\\Installer::install"
{CODE}

Step 2)

Install the following PHP packages (by running these commands on the command line):

{CODE()}
composer require --prefer-dist "jerome-breton/casperjs-installer:dev-master"
composer require --prefer-dist "phpcasperjs/phpcasperjs"
{CODE}

Step 3)

Use the following script to test (in the root of tiki, adjust path if other folder):

{CODE()}
<?php
// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';

use Browser\Casper;

$casper = new Casper(__DIR__ . '/bin/');
$casper->setOptions(array(
  'ignore-ssl-errors' => 'yes'
));

// screen shoot of homepage
$casper
  ->start('http://tiki.org')
  ->setViewPort(1050,1050)
  ->waitForText('About Tiki')
  ->wait(200)
  ->capture(
    array(
      'top' => 0,
      'left' => 0,
      'width' => 1300,
      'height' => 2000
    ),
    'custom-capture.png'
  )
  ->run();

{CODE}



Related: ((dev:Browser Automation))
        

History

Information Version
Marc Laporte was 26
Marc Laporte 25
Marc Laporte 24
Marc Laporte Now easy to install 23
Marc Laporte 22
Marc Laporte 21
Marc Laporte 20
Marc Laporte 19
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 18
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 17
Marc Laporte Edit restored by rescue script 2017-04-24T18:09:12+00:00 16
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 15
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 14
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 13
Xavier de Pedro Edit restored by rescue script 2017-04-24T18:09:12+00:00 12
Xavier de Pedro Version created by rescue script 2017-04-24T18:09:12+00:00 11
Marc Laporte Thank you Ricardo! 10
Marc Laporte 9
Marc Laporte Code Plugin modified by editor. 8
Marc Laporte 7
Marc Laporte 6
Marc Laporte 5
Marc Laporte 4
Marc Laporte 3
Marc Laporte 2