Closed praveenperera closed 9 years ago
@praveenperera Issue with HTTPoison actually. chromedriver has no problems. I've filed an issue https://github.com/edgurgel/httpoison/issues/86. Will wait for the author to take a look.
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.
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
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.
defp deps do
[{:hound, "~> 0.7.6"}]
end
use Mix.Config
config :hound, driver: "chrome_driver"
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 replyI 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: %{}
[{:hound, "~> 1.0"}]
config :hound, browser: "firefox"
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.
@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.
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.Here is my test:
I'm using Hound 0.7.5, thanks
Additional information:
config :hound, driver: "chrome_driver"