.. module:: splinter.driver.webdriver.phantomjs
PhantomJS is a headless WebKit scriptable with a JavaScript API, to use the driver first you must install it in your machine. The Phantomjs WebDriver is provided by Selenium 2.0, thus you need to install Selenium 2.0 via pip:
$ [sudo] pip install selenium
To use the Phantomjs driver, all you need to do is pass the string phantomjs
when you create
the Browser
instance:
from splinter import Browser
browser = Browser('phantomjs')
Note: if you don't provide any driver to Browser
function, firefox
will be used.
PhantomJS can also be used from a custom path. To do this pass the executable path as a dictionary to the **kwargs argument. The dictionary should be set up with executable_path as the key and the value set to the path to the executable file.
from splinter import Browser
executable_path = {'executable_path':'</path/to/phantomjs>'}
browser = Browser('phantomjs', **executable_path)
.. autoclass:: WebDriver
:members:
:inherited-members: