Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hound chrome_driver timeout error #49

Closed
praveenperera opened this issue Oct 27, 2015 · 6 comments
Closed

Hound chrome_driver timeout error #49

praveenperera opened this issue Oct 27, 2015 · 6 comments

Comments

@praveenperera
Copy link
Contributor

I'm trying to get a simple hound test working with my app, I figured out its an error with chrome_driver. I got it works perfectly fine with selenium + firefox and even with selenium + chrome.

However when using with chromedriver as the driver instead of selenium, it opens a new chrome window with data:, in the address bar and then timesout.

19:45:11.959 [error] GenServer Hound.SessionServer terminating
** (MatchError) no match of right hand side value: {:error, %HTTPoison.Error{id: nil, reason: :timeout}}
    (hound) lib/hound/request_utils.ex:43: Hound.RequestUtils.send_req/4
    (hound) lib/hound/session_server.ex:22: Hound.SessionServer.handle_call/3
    (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3


  1) test the truth (MyApp.AuthenticationIntegrationTest)
     test/integrations/authentication_integration_test.exs:7
     ** (exit) exited in: :gen_server.call(Hound.SessionServer, {:find_or_create_session, #PID<0.563.0>}, 60000)
         ** (EXIT) an exception was raised:
             ** (MatchError) no match of right hand side value: {:error, %HTTPoison.Error{id: nil, reason: :timeout}}
                 (hound) lib/hound/request_utils.ex:43: Hound.RequestUtils.send_req/4
                 (hound) lib/hound/session_server.ex:22: Hound.SessionServer.handle_call/3
                 (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
                 (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
                 (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
     stacktrace:
       (stdlib) gen_server.erl:212: :gen_server.call/3
       test/integrations/authentication_integration_test.exs:5: MyApp.AuthenticationIntegrationTest.__ex_unit_setup_0/1
       test/integrations/authentication_integration_test.exs:1: MyApp.AuthenticationIntegrationTest.__ex_unit__/2

Here is my test:

defmodule AuthenticationIntegrationTest do
  use ExUnit.Case
  use Hound.Helpers

  hound_session

  test "the truth" do
    navigate_to("http://localhost:4000")
    assert current_url == "http://localhost:4000"
  end

end

I'm using Hound 0.7.5, thanks

Additional information:

  • config file is as follows: config :hound, driver: "chrome_driver"
  • text.exs has been changed to start the server on test
  • chrome_driver was installed using Homebrew
  • on OSX 10.11.1 El Capitan
@praveenperera praveenperera changed the title Hound HTTPoison Error :econnrefused Hound chrome_driver timeout error Oct 27, 2015
@praveenperera praveenperera changed the title Hound chrome_driver timeout error Hound HTTPoison Error :econnrefused Oct 27, 2015
@praveenperera praveenperera changed the title Hound HTTPoison Error :econnrefused Hound chrome_driver timeout error Oct 27, 2015
@HashNuke
Copy link
Owner

@praveenperera Issue with HTTPoison actually. chromedriver has no problems.
I've filed an issue edgurgel/httpoison#86. Will wait for the author to take a look.

@HashNuke
Copy link
Owner

Header handling was fixed in hackney. In v0.7.6, I've updated the dependency to the latest httpoison. The new release should fix this issue.
If you still have problems please do re-open this issue and let me know.

@stochastic-thread
Copy link

Following this tutorial: https://lord.io/blog/2015/elixir-scraping/

And I'm getting this error:

:ok, []}
iex(2)> Scraper.start
Starting now...

23:11:03.991 [error] GenServer Hound.SessionServer terminating
** (MatchError) no match of right hand side value: {:error, %HTTPoison.Error{id: nil, reason: :econnrefused}}
    (hound) lib/hound/request_utils.ex:43: Hound.RequestUtils.send_req/4
    (hound) lib/hound/session_server.ex:22: Hound.SessionServer.handle_call/3
    (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
    (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:find_or_create_session, #PID<0.168.0>}
State: #HashDict<[]>
** (exit) exited in: :gen_server.call(Hound.SessionServer, {:find_or_create_session, #PID<0.168.0>}, 60000)
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, %HTTPoison.Error{id: nil, reason: :econnrefused}}
            (hound) lib/hound/request_utils.ex:43: Hound.RequestUtils.send_req/4
            (hound) lib/hound/session_server.ex:22: Hound.SessionServer.handle_call/3
            (stdlib) gen_server.erl:629: :gen_server.try_handle_call/4
            (stdlib) gen_server.erl:661: :gen_server.handle_msg/5
            (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
     (stdlib) gen_server.erl:212: :gen_server.call/3
    (scraper) lib/scraper.ex:6: Scraper.start/0

With this mix.exs:

defmodule Scraper.Mixfile do
  use Mix.Project

  def project do
    [app: :scraper,
     version: "0.0.1",
     elixir: "~> 1.1",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps]
  end

  # Configuration for the OTP application
  #
  # Type "mix help compile.app" for more information
  def application do
    [applications: [:logger, :httpoison, :hound]]
  end

  # Dependencies can be Hex packages:
  #
  #   {:mydep, "~> 0.3.0"}
  #
  # Or git/path repositories:
  #
  #   {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
  #
  # Type "mix help deps" for more examples and options
  defp deps do
    [
      {:httpoison, "~> 0.8.0"},
      {:floki,  "~> 0.7.1"},
      {:hound, "~> 0.7.6"}
    ]
  end
end

@luismackmack
Copy link

Hello, i would like write an script for automation browser using hound. In the practice, i have the following issue:


** (MatchError) no match of right hand side value: {:error, %HTTPoison.Error{id: nil, reason: :timeout}}

This is my code, it's very simple.

  • In mix.exs

    defp deps do
    [{:hound, "~> 0.7.6"}]
    end
  • In config/config.exs
    
    use Mix.Config
    config :hound, driver: "chrome_driver"
    
  • In lib/scraper.ex
    
    defmodule Scraper do
      use Hound.Helpers
      def start do
          Application.ensure_all_started(:hound)
          spawn(fn() -> System.cmd("chromedriver", []) end)
          IO.puts "starting"
          Hound.start_session
          navigate_to "https://login.live.com/"
          find_element(:id, "i0116") |> fill_field('Elixir')
          Hound.end_session
      end
    end
    
    Sometimes the script only show the page, rarely it only reaches fill the field, almost always shows that error.
    Thank you in advance for your reply

@ghost
Copy link

ghost commented Aug 28, 2016

I am getting this error when I try to run the test below. There error happens but the browser still launches. It seems like a timing error? I have selenium server running and I can see the sessions it creates on the hub.
13:32:12.294 [error] GenServer Hound.SessionServer terminating ** (MatchError) no match of right hand side value: {:error, :timeout} (hound) lib/hound/session_server.ex:78: Hound.SessionServer.handle_call/3 (stdlib) gen_server.erl:615: :gen_server.try_handle_call/4 (stdlib) gen_server.erl:647: :gen_server.handle_msg/5 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message: {:change_session, #PID<0.215.0>, :default, []} State: %{}

  • In mix.exs [{:hound, "~> 1.0"}]
  • In config.exs config :hound, browser: "firefox"
  • In test/learn_hound_test.exs
defmodule LearnHoundTest do
  use ExUnit.Case
  use Hound.Helpers

  hound_session

  test "the truth"  do
    navigate_to("http://example.com/guestbook.html")

    element = find_element(:name, "message")
    fill_field(element, "Happy Birthday ~!")
    submit_element(element)

    assert page_title() == "Thank you"
  end
end

I am pretty new to Elixir so there could be a problem between the chair and keyboard but at the moment I am at a loss.

@danhper
Copy link
Collaborator

danhper commented Aug 30, 2016

@blackoperat Hi,
I suspect this is not an issue with Hound directly, but with the version of Selenium and Firefox.
Firefox seems to be moving to the geckodriver to communicate with Selenium, so give a try to
Selenium 3.0.0-beta2 with geckodriver (0.10.0 is the latest as writing this), it works perfectly for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants