HashNuke / hound

Elixir library for writing integration tests and browser automation
http://hexdocs.pm/hound
MIT License
1.36k stars 145 forks source link

Getting connection refused. #218

Open lowks opened 6 years ago

lowks commented 6 years ago

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 ?

CaioPenhalver commented 6 years ago

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!

onelesd commented 6 years ago

Have you tried configuring the webdriver port?

config :hound,
  driver: "phantomjs",
  host: "http://localhost",
  port: 8910
phantomjs --webdriver=127.0.0.1:8910
JGjumpshot commented 4 years ago

I have this issue with chromedriver any recommendations? @HashNuke

jaydorsey commented 4 years ago

@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)

philippneugebauer commented 2 years ago

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