Skip to content

dalekjs/dalek-driver-phantomjs

Repository files navigation

No Maintenance Intended

DalekJS is not maintained any longer 😢

We recommend TestCafé for your automated browser testing needs.


dalek-driver-phantomjs - Browser/WebDriver process control

Browser Driver for PhantomJS using GhostDriver providing an API to control the Browser/WebDriver process.

Build Status

Code Climate

Coverage Status

Dependency Status

devDependency Status

Browser / Driver Documentation


API Documentation

var Driver = require('dalek-driver-phantomjs');
var driver = new Driver({
  // path to binary
  // default: provided by phantomjs
  "binary": "/path/to/browser-executable",
  // make the WebDriver instance listen on interface 127.0.0.1
  // default: "127.0.0.1"
  "host": "127.0.0.1",
  // make the WebDriver instance listen on a port between 1111 and 2222
  // default: [2048, 4096]
  "portRange": [1111, 2222],
  // CLI parameters passed to PhantomJS at startup
  // default: (--webdriver=<host:port> --ignore-ssl-errors=true)
  "args": [
    // see http://phantomjs.org/api/command-line.html
    "--local-to-remote-url-access=true"
  ],
});

function success(data) {
  console.log("Started browser, WebDriver available at", data.wd);
}

// callback invoked when the process could not be started
function error(err) {
  console.log("Could not start Browser", err);
}

// callback invoked when the process crashed
function failure(err) {
  console.log("Browser crashed!", err);
}

// fire up the browser and WebDriver service
driver.start(success, error, failure);

// gracefully stop the browser
driver.stop(function() {
  console.log('stopped!');
});

// force kill the process (in case stop() doesn't work)
driver.kill();

a full integration using WD.js could look like

var WD = require('wd');
var Driver = require('dalek-driver-phantomjs');

var wd = wd.promiseChainRemote();
var driver = new Driver({
  name: 'Phantom',
  args: [
    '--local-to-remote-url-access=true'
  ]
});

driver.start(function(options) {
  // initialize WD client from configuration options
  // provided by the browser driver
  wd.remote(options.wd).then(function() {
    // some fun with WebDriver
  });
}, console.log.bind(console));

// stop WD client, then service and browser
wd.quit().then(function() {
  driver.stop();
});

About

[unmaintained] Browser Driver for PhantomJS Web Driver API

Resources

License

Stars

Watchers

Forks

Packages

No packages published