Skip to content
Plugin supports the execution of native PhantomJS or CasperJS scripts. This plugin can be useful in the writing functional tests suites of a website or simple integrations via a web interface.
JavaScript Python Java FreeMarker
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle
src/main
.gitignore
.travis.yml
README.md
build.gradle
gradlew
gradlew.bat
pom.xml

README.md

CasperJS plugin

Overview

Plugin supports the execution of native PhantomJS or CasperJS scripts. This plugin can be useful in the writing functional tests suites of a website or simple integrations via a web interface. It embeds CasperJs 1.1.1b3

Requirements

  • Deployit requirements
    • Deployit: version 4.0.+

Installation

Place the plugin JAR file into your SERVER_HOME/plugins directory.

Usage

Define a casperjs.Runtime container under the desired overthere.Host. The host will be used to stage the PhantomJS runtime and execute the script. The executable property must be set to one of the following depending on the host platform :

  • windows: win/phantomjs.exe
  • osx: osx/phantomjs
  • linux 64-bit: linux_64/phantomjs
  • linux 32-bit: linux_32/phantomjs

If your platform is not supported, you will have to compile PhantomJS for your platform. Please refer to PhantomJS build instructions for details. Place your custom compiled executable in <DEPLOYIT_SERVER_HOME>/ext/phantomjs/runtime/<platform name>.

Define casperjs.ScriptSpec or casperjs.Script deployable items in a package. These deployables are targeted to casperjs.Runtime containers in an environment.

All properties of a deployed can be accessed directly in the script by referring to the deployed javascript variable.

Please refer to PhantomJS and CasperJS sites for detailed documentation on how to write scripts that will run in the headless PhantomJS Webkit.

CasperJS Tests

When running CasperJS test scripts, the isCasperJSTest property must be set to true.

Sample Browser Test

Following sample is from the CasperJS Testing documentation

casper.test.begin('Google search retrieves 10 or more results', 5, function suite(test) {
    casper.start("http://www.google.fr/", function() {
	    test.assertTitle("Google", "google homepage title is the one expected");
    	test.assertExists('form[action="/search"]', "main form is found");
    	this.fill('form[action="/search"]', {
       	 q: "casperjs"
    	}, true);
	});

	casper.then(function() {
    	test.assertTitle("casperjs - Recherche Google", "google title is ok");
    	test.assertUrlMatch(/q=casperjs/, "search term has been submitted");
    	test.assertEval(function() {
        	return __utils__.findAll("h3.r").length >= 10;
    	}, "google search for \"casperjs\" retrieves 10 or more results");
	});

	casper.run(function() {
    	test.done();
	});
});

Sample Browser Test With the deployed ci##

casper.test.begin('Custom search engine retrieve 10 or more results', 5, function suite(test) {
  casper.start("http://"+deployed.container.host.address+":8080/index.html", function() {
      this.echo("URL is: http://"+deployed.container.host.address+":8080/index.html"  , 'INFO');
	    test.assertTitle("Google", "google homepage title is the one expected");
    	test.assertExists('form[action="/search"]', "main form is found");
    	this.fill('form[action="/search"]', {
       	 q: "casperjs"
    	}, true);
	});

	casper.then(function() {
    	test.assertTitle("casperjs - Recherche Google", "google title is ok");
    	test.assertUrlMatch(/q=casperjs/, "search term has been submitted");
    	test.assertEval(function() {
        	return __utils__.findAll("h3.r").length >= 10;
    	}, "google search for \"casperjs\" retrieves 10 or more results");
	});

	casper.run(function() {
    	test.done();
	});
});
You can’t perform that action at this time.