class Driver

webdriver.WebDriver
  └ Driver

Creates a new WebDriver client for PhantomJS.

new Driver(opt_capabilities, opt_flow)

Parameters
opt_capabilities?Capabilities=

The desired capabilities.

opt_flow?webdriver.promise.ControlFlow=

The control flow to use, or null to use the currently active flow.

Instance Methods

<T> executePhantomJS(script, args)code »

Executes a PhantomJS fragment. This method is similar to #executeScript, except it exposes the PhantomJS API to the injected script.

The injected script will execute in the context of PhantomJS's page variable. If a page has not been loaded before calling this method, one will be created.

Be sure to wrap callback definitions in a try/catch block, as failures may cause future WebDriver calls to fail.

Certain callbacks are used by GhostDriver (the PhantomJS WebDriver implementation) and overriding these may cause the script to fail. It is recommended that you check for existing callbacks before defining your own.

As with #executeScript, the injected script may be defined as a string for an anonymous function body (e.g. "return 123;"), or as a function. If a function is provided, it will be decompiled to its original source. Note that injecting functions is provided as a convenience to simplify defining complex scripts. Care must be taken that the function only references variables that will be defined in the page's scope and that the function does not override Function.prototype.toString (overriding toString() will interfere with how the function is decompiled.

Parameters
script(string|Function)

The script to execute.

args?
Returns
webdriver.promise.Promise

A promise that resolve to the script's return value.


setFileDetector()code »

This function is a no-op as file detectors are not supported by this implementation.

Overrides: webdriver.WebDriver