Driver8

Best choice for writing a WebDriver control interface

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. Similar to what Appium does for Mobile testing, you can create your own extension and use it via standard W3C Webdriver wire protocol.

Getting started

If you want to give it a try right away, 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-dev"}
    ]
  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.Adapters.Cowboy.child_spec(
        scheme: :http,
        plug: Driver8.Plug,
        options: [ port: 8085 ]
      ), 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.0. 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 a simple extension

...