Ghost Driver PC Settings: Setup Guide & Configuration - Settings

Ghost Driver PC Settings: Setup Guide & Configuration

Learn how to configure Ghost Driver PC settings for Selenium and PhantomJS. Step-by-step setup, capabilities, and optimization tips.

2026-08-12
Ghost Driver Wiki Team
Quick Guide
  • Ghost Driver PC settings: Configure PhantomJS bindings for Selenium WebDriver automation
  • Core architecture: Ghost Driver runs as a JavaScript implementation inside PhantomJS
  • Essential capability: Set phantomjs.binary.path to point to your local executable
  • Headless advantage: No display server required, ideal for CI/CD pipelines
  • Custom switches: Pass CLI arguments via phantomjs.cli.args for SSL and rendering control

Understanding Ghost Driver and PC Settings

Ghost Driver serves as the WebDriver implementation built into PhantomJS, enabling headless browser automation through the W3C WebDriver protocol. When configuring Ghost Driver PC settings, you are essentially bridging your Selenium client tests with the PhantomJS headless browser engine.

Video Highlights:

  • Explains the dual nature of Ghost Driver as both a script and an embedded module
  • Covers the sequence diagram of what happens during driver initialization
  • Demonstrates how to pass custom capabilities and CLI arguments
  • Details the differences between PhantomJS and HTMLUnit for testing

When you initialize a new PhantomJSDriver instance in your test suite, the system creates a driver service that spawns a separate PhantomJS process. This process executes the Ghost Driver script, which then listens on a local endpoint for WebDriver commands. Understanding this flow is critical for optimizing your local PC settings.

Binding vs Driver

Do not confuse Ghost Driver with PhantomJSDriver bindings. Ghost Driver is the JavaScript implementation running inside PhantomJS. PhantomJSDriver refers to the Selenium client bindings (the classes you import in your test scripts) that communicate with Ghost Driver via HTTP.

ComponentTypeLanguageRole
Ghost DriverWebDriver ImplementationJavaScriptRuns inside PhantomJS, handles W3C protocol
PhantomJSDriverClient BindingJava/Python/Ruby/.NETClasses used in test scripts to launch the browser
PhantomJSHeadless BrowserC++WebKit-based engine executing the page rendering
Selenium GridHub/Node ArchitectureVariousDistributes test instances across machines

Essential PC Configuration Parameters

Configuring Ghost Driver PC settings requires defining specific Desired Capabilities in your Selenium tests. These capabilities tell the binding where the PhantomJS executable is located and how to launch it.

The most critical setting is phantomjs.binary.path. Without this parameter, your test script will not know where to find the PhantomJS executable on your machine. Additionally, you can pass command-line arguments directly to the PhantomJS process using phantomjs.cli.args.

Executable Path

Always verify that the path provided in phantomjs.binary.path points to the actual executable file, not just the directory. An incorrect path is the most common cause of initialization failures.

Capability KeyPurposeExample Value
phantomjs.binary.pathPoints to the PhantomJS executable/usr/local/bin/phantomjs
phantomjs.ghostdriver.pathPoints to a custom Ghost Driver script (for contributors)/path/to/ghostdriver/main.js
phantomjs.cli.argsArray of CLI arguments passed to the process["--ignore-ssl-errors=true"]
phantomjs.page.settings.XOverrides page object properties (e.g., userAgent)Mozilla/5.0 (iPhone...)

Binary Path

  • Required for local execution
  • Must point directly to the executable file
  • Use absolute paths to avoid resolution errors

CLI Arguments

  • Passed as an array of strings
  • Supports SSL error ignoring
  • Enables remote debugger configuration

Page Settings

  • Overrides default browser properties
  • Custom User-Agent strings
  • Applied to every new session

Step-by-Step Setup Guide

Follow these steps to configure Ghost Driver PC settings on your local machine. This guide assumes you have a basic Selenium project already set up in your preferred programming language.

1

Download PhantomJS

Download the appropriate PhantomJS build for your operating system from the official website. Unzip the package and note the location of the executable file. Alternatively, you can build PhantomJS from source, though this process can take over an hour on fast machines since it compiles the entire WebKit engine.

2

Add Selenium Bindings

Add the Selenium WebDriver bindings to your project. In Java, include the selenium-java and selenium-server dependencies via Maven or Gradle. For Python, simply install the selenium package. The PhantomJSDriver classes are bundled within the standard Selenium library.

3

Configure Desired Capabilities

Create a DesiredCapabilities object and set the phantomjs.binary.path capability to the absolute path of your PhantomJS executable. Add any necessary CLI arguments to the phantomjs.cli.args capability array.

4

Initialize the Driver

Pass the configured capabilities object to a new PhantomJSDriver instance. The driver service will automatically spawn the PhantomJS process, execute Ghost Driver, and establish a WebDriver session.

5

Run Tests Headlessly

Execute your test suite. PhantomJS will run completely headlessly without popping up browser windows, making it ideal for continuous integration environments and command-line execution.

Setup Verification

After initialization, your test script will poll the /status endpoint on the local port. Once it receives an HTTP 200 OK response, a new session is created automatically. You can then use standard WebDriver commands like driver.get(url) to navigate.

SSL, Security, and Grid Settings

When running automated tests against internal or staging environments, you frequently encounter self-signed SSL certificates. Ghost Driver PC settings provide specific capabilities to handle these scenarios gracefully.

To ignore SSL certificate errors, pass the --ignore-ssl-errors=true argument through the phantomjs.cli.args capability. You can also pass --web-security=false to disable same-origin policy checks during testing.

Security Implications

Only disable SSL verification and web security in testing environments. Never use these settings in production or when handling sensitive user data.

CLI ArgumentEffectUse Case
--ignore-ssl-errors=trueBypasses all certificate validation errorsInternal staging servers with self-signed certs
--web-security=falseDisables cross-origin security policiesTesting iframe interactions and CORS behavior
--remote-debugger-port=9000Enables remote debugging via Web InspectorDebugging Ghost Driver JavaScript code
--webdriver=8080Sets a custom port for the WebDriver listenerRunning multiple instances simultaneously

For Selenium Grid integration, you can register your PhantomJS instance to a hub by passing the --webdriver-selenium-grid-hub parameter with the hub URL. This allows the grid to distribute PhantomJS instances across multiple test machines.

Remote Debugging

To debug Ghost Driver internals, start PhantomJS with --remote-debugger-port=9000 and --remote-debugger-autorun=yes. Open Chrome or Safari's Web Inspector and connect to the PhantomJS instance to step through the JavaScript code.

Advanced Customization and Limitations

Ghost Driver PC settings support advanced page-level customizations through the phantomjs.page.settings capability prefix. This allows you to override properties on every page object created during a session.

A common use case is overriding the User-Agent string. Some websites filter traffic based on User-Agent to block screen scraping. By setting a custom User-Agent, you can simulate different devices such as iOS or Android browsers.

Page SettingDescriptionCommon Value
userAgentOverrides the browser User-Agent stringMozilla/5.0 (iPhone; CPU iPhone OS 10_0...)
javascriptEnabledEnables or disables JavaScript executiontrue
loadImagesControls whether images are loadedfalse (for faster scraping)
resourceTimeoutSets maximum resource load time in ms10000
Current Limitations

As of version 1.0.2, several WebDriver commands are not yet implemented in Ghost Driver. Missing features include the Touch API, geolocation API, mobile emulation, local storage manipulation, and alert/confirm/prompt handling. Check the official implementation spreadsheet for current status.

Optimization Checklist:

  • Set phantomjs.binary.path to absolute executable location
  • Disable image loading for faster scraping performance
  • Pass --ignore-ssl-errors=true for internal testing
  • Override User-Agent when testing responsive layouts
  • Register with Selenium Grid for distributed testing

Frequently Asked Questions

Q: What is the difference between Ghost Driver and PhantomJS?

PhantomJS is a headless WebKit browser written in C++. Ghost Driver is a JavaScript implementation of the WebDriver protocol that runs inside PhantomJS. When you configure Ghost Driver PC settings, you are telling Selenium how to communicate with PhantomJS through the Ghost Driver interface.

Q: How do I pass custom command-line arguments to PhantomJS?

Use the `phantomjs.cli.args` desired capability. Pass an array of strings where each string represents a CLI argument. For example, to ignore SSL errors, set the capability to an array containing `--ignore-ssl-errors=true`.

Q: Can I use Ghost Driver with Selenium Grid?

Yes. Start PhantomJS with the `--webdriver-selenium-grid-hub` parameter followed by your hub URL. The PhantomJS instance will automatically register itself with the grid and become available for distributed test execution.

Q: Why does my test fail with 'not implemented' errors?

Ghost Driver does not yet implement every WebDriver command. The Touch API, geolocation, local storage, and alert handling are among the features not currently supported. Check the official implementation status spreadsheet to verify if your specific command is available.