WebDriver

This is the Elixir WebDriver application. It can be used to drive a WebDriver enabled browser via Elixir code.

The current version supports PhantomJS, ChromeDriver, FireFox and remote Web Driver servers (e.g. Selenium).

All drivers except ‘remote’ manage running the browser in the application supervision tree.

This code is written to be very similar to the Selenium bindings for other languages.

Source

Summary

browsers()

Returns a list of the process names of all browsers that are running

sessions()

Returns a list of all the process names of all sessions that are running

sessions(browser)

Returns a list of all the process names of sessions running on the specified browser

start(atom1, config)

Start the application. This is a callback called by :application.start :webdriver and should probably not be called directly

start_browser(config)

Start a browser with the given configuration. The config parameter is a WebDriver.Config struct defined as

start_session(browser, session_name)

Start a session on the specified browser. You must specify a name for the session in order to refer to it for further calls to the Session module

stop(arg1)

Callback to clean up on exit. Currently does nothing much

stop_all_browsers()

Stops all browsers and sessions that are running

stop_browser(name)

Stop the web browser referred to by name. You can also use the pid of the process if you wish. This causes the browser and all associated sessions to be terminated

stop_session(session_name)

Stop session. Kill a session on the current browser. This will attempt to terminate the session in the browser then it will stop the process running the session in the VM

Functions

browsers()

Returns a list of the process names of all browsers that are running.

Source
sessions()

Returns a list of all the process names of all sessions that are running.

Source
sessions(browser)

Returns a list of all the process names of sessions running on the specified browser.

Source
start(atom1, config)

Start the application. This is a callback called by :application.start :webdriver and should probably not be called directly.

Source
start_browser(config)

Start a browser with the given configuration. The config parameter is a WebDriver.Config struct defined as

defstruct browser: :phantomjs, name: nil, root_url: ""

Currently Config is very minimal, future versions will add to this. Browser can be eithes :phantomjs or :firefox.

Note that at the moment Firefox support is highly experimental.

The name parameter is an atom with which you can reference the browser process for further calls.

Returns {:ok, pid} or {:error, reason}

Example:

iex> config = %WebDriver.Config{browser: :phantomjs, name: :test_browser}
iex> WebDriver.start_browser config
Starting phantomjs
Phantom js started
{:ok,#PID<0.235.0>}
Source
start_session(browser, session_name)

Start a session on the specified browser. You must specify a name for the session in order to refer to it for further calls to the Session module.

Returns {:ok, pid} or {:error, reason}

Source
stop(arg1)

Callback to clean up on exit. Currently does nothing much.

Source
stop_all_browsers()

Stops all browsers and sessions that are running.

Source
stop_browser(name)

Stop the web browser referred to by name. You can also use the pid of the process if you wish. This causes the browser and all associated sessions to be terminated.

Source
stop_session(session_name)

Stop session. Kill a session on the current browser. This will attempt to terminate the session in the browser then it will stop the process running the session in the VM.

Source