diff --git a/lib/wallaby/session_store.ex b/lib/wallaby/session_store.ex index f666b3fc..7f5a0f59 100644 --- a/lib/wallaby/session_store.ex +++ b/lib/wallaby/session_store.ex @@ -36,16 +36,18 @@ defmodule Wallaby.SessionStore do Process.flag(:trap_exit, true) tid = :ets.new(name, opts) - Application.ensure_all_started(:ex_unit) - - ExUnit.after_suite(fn _ -> - try do - :ets.tab2list(tid) - |> Enum.each(&delete_sessions/1) - rescue - _ -> nil - end - end) + if Code.ensure_loaded?(ExUnit) do + Application.ensure_all_started(:ex_unit) + + ExUnit.after_suite(fn _ -> + try do + :ets.tab2list(tid) + |> Enum.each(&delete_sessions/1) + rescue + _ -> nil + end + end) + end {:ok, %{ets_table: tid}} end diff --git a/lib/wallaby/webdriver_client.ex b/lib/wallaby/webdriver_client.ex index 92adf7d6..abbe5785 100644 --- a/lib/wallaby/webdriver_client.ex +++ b/lib/wallaby/webdriver_client.ex @@ -23,7 +23,13 @@ defmodule Wallaby.WebdriverClient do def create_session(base_url, capabilities) do params = %{desiredCapabilities: capabilities} - request(:post, "#{base_url}session", params) + case request(:post, "#{base_url}session", params) do + {:ok, %{"status" => status} = nonzero_status_response} when status != 0 -> + {:error, nonzero_status_response} + + response -> + response + end end @doc """