README.md

# Driver8

**Best choice for writing a [WebDriver](https://www.w3.org/TR/webdriver/) remote end**

Driver8 provides everything you need to build a Webdriver extension. This is *not* a wrapper for
your Selenium tests, but a basis for [Remote end](https://www.w3.org/TR/webdriver/#dfn-remote-ends).
Similar to what [Appium](http://appium.io/) does for Mobile testing, you can create your own extension and
use it via standard W3C Webdriver wire protocol.

## Getting started
You can give the Driver8 a try without adding any functionality. Driver8 has two components:
 * `Driver8.Plug` -  [Plug](https://hexdocs.pm/plug/readme.html) that takes care of capturing REST requests to your driver
 * `Driver8` - Main process (in a form of [GenServer](https://hexdocs.pm/elixir/GenServer.html)) that handles the requests 
 passed to it by `Driver8.Plug` or any other process.

To bootstrap Driver8 application you will need a http server. For this demo we will use [Cowboy](https://hex.pm/packages/cowboy)
server. Run `mix new demo` to create a new mix application called `demo`. Switch to your demo folder `cd demo`. Change 
your mix.exs to look like this (project section should already look like this, you simply need to adjust application and deps sections):

  defmodule Demo.MixProject do
  use Mix.Project
      def project do
        [
          app: :demo,
          version: "0.1.0",
          elixir: "~> 1.10",
          start_permanent: Mix.env() == :prod,
          deps: deps()
        ]
      end

      def application do
        [
          extra_applications: [:logger, :cowboy, :plug, :jason, :eex],
          mod: {Demo, []},
          env: [
            port: 8085
          ]
        ]
      end

      defp deps do
        [
          {:httpoison, "~> 1.6"},
          {:plug_cowboy, "~> 2.0"},
          {:driver8, "~> 0.1"}
        ]
      end
  end

Now update your main module `Demo` (found in `lib/demo.ex`) to look like this:

  defmodule Demo do
      use Application

      def start(_type, _args) do
        children = [
          {Plug.Cowboy,
           scheme: :http,
           plug: Driver8.Plug,
           options: [port: Application.fetch_env!(:driver8, :port) |> IO.inspect()]},
          Driver8
        ]
        
        Supervisor.start_link(children, [strategy: :one_for_one, name: Demo.Supervisor])
      end
  end

After that you need to get dependencies by running `mix deps.get`. Now you can start application by running `iex -S mix`.
If all goes according to plan then after you open your browser and point it at [http://localhost:8085/]() you should see a
greeting message similar to this: `You are using Driver 8 (elixir) 0.1.2`. Another route that should work is [http://localhost:8085/status]().
It should return you a json with a message and `ready` status of the driver process.

Congrats, you are running you very own webdriver extension! It can handle session creation, but that is about it. So let's
make it a bit more interesting.

## Adding functionality
Now you know how to get an webdriver application up and running. The whole point is to be able to extend
webdriver protocol and to run an awesome command you want to create. For that you simply need to create a
GenServer and tell the `Driver8.Session` which prefix you want to be registered on. Check out `Driver8` module docs
for session extension example.