HashNuke / hound

Elixir library for writing integration tests and browser automation

Home Page:http://hexdocs.pm/hound

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting connection refused.

lowks opened this issue · comments

I am trying to setup hound to run for my project. In mix.exs I added the dependencies:

{:hound, "~> 1.0"}

My config/test.exs looks like this:

+config :hound, driver: "phantomjs"

My test looks like this:

defmodule BasicBrowserSessionTest do
  use ExUnit.Case
  use Hound.Helpers

  hound_session

  test "Basic test." do
    url1 = "http://www.abc.com"
    navigate_to(url1)  
  end
end

The error I get:

BasicBrowserSessionTest
  * test Basic Test. (1057.3ms)
03:36:08.360 [error] GenServer Hound.SessionServer terminating
** (RuntimeError) could not create a new session: econnrefused, check webdriver is running
    (hound) lib/hound/session_server.ex:101: Hound.SessionServer.create_session/2
    (hound) lib/hound/session_server.ex:78: Hound.SessionServer.handle_call/3
    (stdlib) gen_server.erl:636: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:665: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message (from #PID<0.598.0>): {:change_session, #PID<0.598.0>, :default, []}

My test_helper.exs

Application.ensure_all_started(:hound)
{:ok, _} = Application.ensure_all_started(:ex_machina)
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(UrboxApi.Repo, :manual)

I run phantomjs in another session by issuing the command phantomjs --wd

Can someone let me know what I am missing here ?

I'm having the same problem here. I mean I'm not pretty sure if it's a issue or if it's the way that supposed to be!

Have you tried configuring the webdriver port?

config :hound,
  driver: "phantomjs",
  host: "http://localhost",
  port: 8910
phantomjs --webdriver=127.0.0.1:8910

I have this issue with chromedriver any recommendations? @HashNuke

@JGjumpshot I may be remembering incorrectly, but I think chromedriver (thru homebrew) used to be managed thru brew services (and may have started automatically even?), but that appears to have changed so you probably manually need to start it.

You may need to configure the port, per the earlier comment, and start the chromedriver with chromedriver (assuming it's on your path). When you start it, it will output which port it's running on (you can also specify via chromedriver options when you start it)

If you installed chromedriver via brew, you need to execute /usr/local/bin/chromedriver or the output of which chromedriver