Closed stochastic-thread closed 8 years ago
Additional information:
I created this test:
defmodule ScraperTest do
use ExUnit.Case
use Hound.Helpers
hound_session
test "the truth", meta do
navigate_to("http://example.com/guestbook.html")
find_element(:name, "message")
|> fill_field("Happy Birthday ~!")
|> submit_element()
assert page_title() == "Thank you"
end
end
and received this output:
➜ scraper iex -S test
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
** (UnicodeConversionError) invalid encoding starting at <<207, 250, 237, 254, 7, 0, 0, 1, 3, 0, 0, 128, 2, 0, 0, 0, 16, 0, 0, 0, 80, 6, 0, 0, 133, 0, 32, 0, 0, 0, 0, 0, 25, 0, 0, 0, 72, 0, 0, 0, 95, 95, 80, 65, 71, 69, 90, 69, 82, 79, ...>>
(elixir) lib/string.ex:1418: String.to_char_list/1
(elixir) lib/code.ex:363: Code.require_file/2
➜ scraper
➜ scraper a
zsh: command not found: a
➜ scraper mix test
==> idna (compile)
WARN: Missing plugins: [rebar3_hex]
==> mimerl (compile)
==> ssl_verify_hostname (compile)
==> poison
Compiled lib/poison.ex
Compiled lib/poison/parser.ex
Compiled lib/poison/decoder.ex
Compiled lib/poison/encoder.ex
Generated poison app
==> certifi (compile)
==> hackney (compile)
==> httpoison
Compiled lib/httpoison/base.ex
Compiled lib/httpoison.ex
Generated httpoison app
==> hound
Compiled lib/hound/helpers.ex
Compiled lib/hound.ex
Compiled lib/hound/connection_server.ex
Compiled lib/hound/matchers.ex
Compiled lib/hound/helpers/session.ex
lib/hound/response_parser_utils.ex:4: warning: unused import Logger
Compiled lib/hound/response_parser_utils.ex
Compiled lib/hound/response_parsers/chrome_driver.ex
Compiled lib/hound/internal_helpers.ex
Compiled lib/hound/request_utils.ex
Compiled lib/hound/response_parsers/phantom_js.ex
Compiled lib/hound/response_parsers/selenium.ex
Compiled lib/hound/helpers/script_execution.ex
Compiled lib/hound/session.ex
Compiled lib/hound/helpers/screenshot.ex
Compiled lib/hound/helpers/window.ex
Compiled lib/hound/helpers/orientation.ex
Compiled lib/hound/helpers/navigation.ex
Compiled lib/hound/helpers/dialog.ex
Compiled lib/hound/helpers/page.ex
Compiled lib/hound/helpers/cookie.ex
Compiled lib/hound/supervisor.ex
lib/hound/matchers/text.ex:67: warning: variable error is unused
lib/hound/matchers/text.ex:69: warning: variable error is unused
Compiled lib/hound/matchers/text.ex
Compiled lib/hound/session_server.ex
Compiled lib/hound/helpers/element.ex
Generated hound app
==> mochiweb (compile)
==> floki
Compiled src/floki_selector_lexer.erl
Compiled lib/floki/combinator.ex
Compiled lib/floki/deep_text.ex
Compiled lib/floki/filter_out.ex
Compiled lib/floki/attribute_selector.ex
Compiled lib/floki/flat_text.ex
Compiled lib/floki/parser.ex
Compiled lib/floki/finder.ex
Compiled lib/floki/selector_tokenizer.ex
Compiled lib/floki.ex
Compiled lib/floki/selector.ex
Compiled lib/floki/selector_parser.ex
Generated floki app
==> scraper
Compiled lib/scraper.ex
Generated scraper app
test/scraper_test.exs:7: warning: variable meta is unused
23:14:36.599 [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.587.0>}
State: #HashDict<[]>
1) test the truth (ScraperTest)
test/scraper_test.exs:7
** (exit) exited in: :gen_server.call(Hound.SessionServer, {:find_or_create_session, #PID<0.587.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
stacktrace:
(stdlib) gen_server.erl:212: :gen_server.call/3
test/scraper_test.exs:5: ScraperTest.__ex_unit_setup_0/1
test/scraper_test.exs:1: ScraperTest.__ex_unit__/2
Finished in 0.1 seconds (0.06s on load, 0.08s on tests)
1 test, 1 failure
Randomized with seed 467310
➜ scraper mix test
test/scraper_test.exs:7: warning: variable meta is unused
23:20:12.187 [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.166.0>}
State: #HashDict<[]>
1) test the truth (ScraperTest)
test/scraper_test.exs:7
** (exit) exited in: :gen_server.call(Hound.SessionServer, {:find_or_create_session, #PID<0.166.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
stacktrace:
(stdlib) gen_server.erl:212: :gen_server.call/3
test/scraper_test.exs:5: ScraperTest.__ex_unit_setup_0/1
test/scraper_test.exs:1: ScraperTest.__ex_unit__/2
Finished in 0.2 seconds (0.1s on load, 0.1s on tests)
1 test, 1 failure
Randomized with seed 36365
Additional information 2:
Created directory dev_deps
to mess around with dependencies that don't work, in this case, hound
Ran git clone https://github.com/HashNuke/hound
and did the following:
➜ dev_deps git clone https://github.com/HashNuke/hound
Cloning into 'hound'...
remote: Counting objects: 2316, done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 2316 (delta 26), reused 0 (delta 0), pack-reused 2258
Receiving objects: 100% (2316/2316), 313.32 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1423/1423), done.
Checking connectivity... done.
➜ dev_deps cd hound
➜ hound git:(master) iex -S mix
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Unchecked dependencies for environment dev:
* poison (Hex package)
the dependency is not available, run "mix deps.get"
* httpoison (Hex package)
the dependency is not available, run "mix deps.get"
** (Mix) Can't continue due to errors on dependencies
➜ hound git:(master) mix deps.get
Running dependency resolution
* Getting httpoison (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/httpoison-0.8.0.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/httpoison-0.8.0.tar)
* Getting poison (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/poison-1.4.0.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/poison-1.4.0.tar)
* Getting earmark (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/earmark-0.1.18.tar)
Fetched package
Unpacked package tarball (/Users/arthur/.hex/packages/earmark-0.1.18.tar)
* Getting ex_doc (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/ex_doc-0.10.0.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/ex_doc-0.10.0.tar)
* Getting hackney (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/hackney-1.4.4.tar)
Fetched package
Unpacked package tarball (/Users/arthur/.hex/packages/hackney-1.4.4.tar)
* Getting ssl_verify_hostname (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/ssl_verify_hostname-1.0.5.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/ssl_verify_hostname-1.0.5.tar)
* Getting mimerl (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/mimerl-1.0.0.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/mimerl-1.0.0.tar)
* Getting idna (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/idna-1.0.2.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/idna-1.0.2.tar)
* Getting certifi (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/certifi-0.1.1.tar)
Using locally cached package
Unpacked package tarball (/Users/arthur/.hex/packages/certifi-0.1.1.tar)
➜ hound git:(master) ls
LICENSE README.md TODO deps lib mix.exs mix.lock notes test
➜ hound git:(master) iex -S mix
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
==> idna (compile)
Compiled src/idna_unicode.erl
Compiled src/punycode.erl
Compiled src/idna.erl
Compiled src/idna_ucs.erl
Compiled src/idna_unicode_data.erl
WARN: Missing plugins: [rebar3_hex]
==> mimerl (compile)
Compiled src/mimerl.erl
==> ssl_verify_hostname (compile)
Compiled src/ssl_verify_hostname.erl
==> poison
Compiled lib/poison.ex
Compiled lib/poison/parser.ex
Compiled lib/poison/decoder.ex
Compiled lib/poison/encoder.ex
Generated poison app
WARN: Missing plugins: [rebar3_hex]
==> certifi (compile)
Compiled src/certifi.erl
Compiled src/certifi_pemcerts.erl
==> hackney (compile)
Compiled src/socket/hackney_tcp_transport.erl
Compiled src/socket/hackney_ssl_transport.erl
Compiled src/socket/hackney_socks5.erl
Compiled src/socket/hackney_pool_handler.erl
Compiled src/socket/hackney_http_connect.erl
Compiled src/metrics/hackney_folsom_metrics.erl
Compiled src/metrics/hackney_exometer_metrics.erl
Compiled src/metrics/hackney_dummy_metrics.erl
Compiled src/socket/hackney_pool.erl
Compiled src/socket/hackney_connect.erl
Compiled src/http/hackney_url.erl
Compiled src/http/hackney_response.erl
Compiled src/http/hackney_multipart.erl
Compiled src/http/hackney_request.erl
Compiled src/http/hackney_http.erl
Compiled src/http/hackney_cookie.erl
Compiled src/http/hackney_date.erl
Compiled src/http/hackney_headers.erl
Compiled src/hackney_util.erl
Compiled src/hackney_sup.erl
Compiled src/hackney_trace.erl
Compiled src/http/hackney_bstr.erl
Compiled src/hackney_app.erl
Compiled src/hackney_stream.erl
Compiled src/hackney_manager.erl
Compiled src/hackney.erl
==> httpoison
Compiled lib/httpoison/base.ex
Compiled lib/httpoison.ex
Generated httpoison app
==> hound
Compiled lib/hound/helpers.ex
Compiled lib/hound.ex
Compiled lib/hound/connection_server.ex
Compiled lib/hound/helpers/session.ex
lib/hound/response_parser_utils.ex:4: warning: unused import Logger
Compiled lib/hound/response_parser_utils.ex
Compiled lib/hound/response_parsers/chrome_driver.ex
Compiled lib/hound/request_utils.ex
Compiled lib/hound/internal_helpers.ex
Compiled lib/hound/response_parsers/phantom_js.ex
Compiled lib/hound/response_parsers/selenium.ex
Compiled lib/hound/helpers/script_execution.ex
Compiled lib/hound/helpers/screenshot.ex
Compiled lib/hound/helpers/window.ex
Compiled lib/hound/helpers/orientation.ex
Compiled lib/hound/helpers/dialog.ex
Compiled lib/hound/helpers/navigation.ex
Compiled lib/hound/helpers/cookie.ex
Compiled lib/hound/helpers/page.ex
Compiled lib/hound/session.ex
Compiled lib/hound/supervisor.ex
Compiled lib/hound/helpers/element.ex
Compiled lib/hound/session_server.ex
Compiled lib/hound/matchers.ex
Generated hound app
Interactive Elixir (1.1.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
c
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
(v)ersion (k)ill (D)b-tables (d)istribution
a
➜ hound git:(master) mix test
==> idna (compile)
WARN: Missing plugins: [rebar3_hex]
==> mimerl (compile)
==> ssl_verify_hostname (compile)
==> poison
Compiled lib/poison.ex
Compiled lib/poison/parser.ex
Compiled lib/poison/decoder.ex
Compiled lib/poison/encoder.ex
Generated poison app
WARN: Missing plugins: [rebar3_hex]
==> certifi (compile)
==> hackney (compile)
==> httpoison
Compiled lib/httpoison/base.ex
Compiled lib/httpoison.ex
Generated httpoison app
==> hound
Compiled lib/hound/helpers.ex
Compiled lib/hound.ex
Compiled lib/hound/connection_server.ex
Compiled lib/hound/helpers/session.ex
lib/hound/response_parser_utils.ex:4: warning: unused import Logger
Compiled lib/hound/response_parser_utils.ex
Compiled lib/hound/response_parsers/chrome_driver.ex
Compiled lib/hound/internal_helpers.ex
Compiled lib/hound/request_utils.ex
Compiled lib/hound/response_parsers/selenium.ex
Compiled lib/hound/response_parsers/phantom_js.ex
Compiled lib/hound/helpers/window.ex
Compiled lib/hound/session.ex
Compiled lib/hound/helpers/screenshot.ex
Compiled lib/hound/helpers/script_execution.ex
Compiled lib/hound/helpers/orientation.ex
Compiled lib/hound/helpers/navigation.ex
Compiled lib/hound/helpers/dialog.ex
Compiled lib/hound/helpers/cookie.ex
Compiled lib/hound/helpers/page.ex
Compiled lib/hound/supervisor.ex
Compiled lib/hound/session_server.ex
Compiled lib/hound/helpers/element.ex
Compiled lib/hound/matchers.ex
Generated hound app
"Stopping Hound and restarting with options for test suite..."
23:27:55.639 [info] Application hound exited: :stopped
23:27:56.295 [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.529.0>}
State: #HashDict<[]>
** (EXIT from #PID<0.47.0>) shutdown
1) test Input into prompt (DialogTest)
test/helpers/dialog_test.exs:32
** (exit) exited in: :gen_server.call(Hound.SessionServer, {:find_or_create_session, #PID<0.529.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
stacktrace:
(stdlib) gen_server.erl:212: :gen_server.call/3
test/helpers/dialog_test.exs:7: DialogTest.__ex_unit_setup_0/1
test/helpers/dialog_test.exs:1: DialogTest.__ex_unit__/2
23:27:56.314 [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.534.0>}
State: #HashDict<[]>
2) test Accept dialog (DialogTest)
test/helpers/dialog_test.exs:24
** (exit) exited in: :gen_server.call(Hound.SessionServer, {:find_or_create_session, #PID<0.534.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
stacktrace:
(stdlib) gen_server.erl:212: :gen_server.call/3
test/helpers/dialog_test.exs:7: DialogTest.__ex_unit_setup_0/1
test/helpers/dialog_test.exs:1: DialogTest.__ex_unit__/2
23:27:56.343 [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.536.0>}
State: #HashDict<[]>
23:27:56.355 [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.538.0>}
State: #HashDict<[]>
Let me know if I can do anything to help debug, maybe Selenium isn't running in the background?
@arthurcolle Are you running Selenium or Phantomjs or Chrome driver in the background or another shell?
@arthurcolle Looks like you aren't running any webdriver in the background.
From the readme:
You'll need a webdriver server running, like Selenium Server or Chrome Driver. If you aren't sure what it is, then read this.
If you want to use Phantomjs or Chromedriver directly, then you can do it by configuring Hound appropriately - https://github.com/HashNuke/hound/blob/master/notes/configuring-hound.md
To run the tests within Hound, you'll need to export an env var with the name of the webdriver like WEBDRIVER=phantomjs
. The .travis.yml config has info about this.
For anyone else unfamiliar with starting a webdriver server that's getting this issue, running the following in another terminal got the PhantomJS webdriver working for me:
$ phantomjs --wd
@bchase Thank you. I just went around checking the repo. Looks like I assumed too much that people will know that. I'll add more information about it.
No success here. Phantomjs is running, tests ran with
WEBDRIVER=phantomjs mix test
Still the same error
OS: Vagrant Ubuntu 14.04
Ok. Setting
config :hound, driver: "phantomjs"
In config.exs fixed the problem
Although that should be better documented in README file
It can be understood as if WEBDRIVER=phantomjs
should be enough
@HashNuke
I followed tutorial http://hashnuke.com/2015/06/07/hound-phoenix-framework-integration-testing.html and http://blog.plataformatec.com.br/2016/01/writing-acceptance-tests-in-phoenix/
But when i execute mix test i get these error.
Consolidated Inspect ...
1) test GET Phoenix framework page (Hello.SampleTest) test/sample_test.exs:14 * (exit) exited in: GenServer.call(Hound.SessionServer, {:change_session, #PID<0.475.0>, :default, %{}}, 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:67: 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: (elixir) lib/gen_server.ex:564: GenServer.call/3 test/sample_test.exs:11: Hello.SampleTest.ex_unit_setup_1/1 test/sample_test.exs:2: Hello.SampleTest.__ex_unit/2
2) test should fill a field with a value (Hello.SampleTest) test/sample_test.exs:29 * (exit) exited in: GenServer.call(Hound.SessionServer, {:change_session, #PID<0.480.0>, :default, %{}}, 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:67: 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: (elixir) lib/gen_server.ex:564: GenServer.call/3 test/sample_test.exs:11: Hello.SampleTest.ex_unit_setup_1/1 test/sample_test.exs:2: Hello.SampleTest.__ex_unit/2
10:05:59.431 [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:67: 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 10:05:59.432 [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:67: 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 .
Finished in 0.4 seconds (0.2s on load, 0.2s on tests) 6 tests, 2 failures
Randomized with seed 199676`>
This is my test/sample_test.exs file defmodule Hello.SampleTest do use Hello.ConnCase use ExUnit.Case
use Hound.Helpers
hound_session
test "GET Phoenix framework page" do navigate_to("http://localhost:4000") :timer.sleep(9000) # puts server to sleep assert page_source =~ "Welcome to Phoenix" assert("Hello HelloPhoenix!" == page_title) end
test "should fill a field with a value" do navigate_to "https://accounts.google.com/AddSession?hl=en&continue=https://mail.google. com/mail&service=mail#identifier" IO.puts " " IO.puts current_url :timer.sleep(8000) element_id = find_element(:name, "Email") fill_field(element_id, "myemail@gmail.com") :timer.sleep(8000) # puts server to sleep assert attribute_value(element_id, "value") == "myemail@gmail.com" element_id = find_element(:id, "next") click element_id IO.puts current_url :timer.sleep(2000) element_id = find_element(:id, "Passwd") fill_field(element_id, "mypassword") :timer.sleep(8000) # puts server to sleep assert attribute_value(element_id, "value") == "mypassword" element_id = find_element(:id, "signIn") click element_id :timer.sleep(9000) # puts server to sleep end end
This is my config/config.exs file
use Mix.Config config :hello, Hello.Endpoint, url: [host: "localhost"], root: Path.dirname(DIR), secret_key_base: "13uOu4yUSaAqVY4twbhbKpPleQM5X8oypM77tSdGsmhX/HFPk/yM275wtV3hNMoc", render_errors: [accepts: ~w(html json)], pubsub: [name: Hello.PubSub, adapter: Phoenix.PubSub.PG2] config :logger, :console, format: "$time $metadata[$level] $message\n", metadata: [:request_id]
import_config "#{Mix.env}.exs" config :hound, driver: "phantomjs"
This is my mix.exs file
defmodule Hello.Mixfile do use Mix.Project
def project do [app: :hello, version: "0.0.1", elixir: "~> 1.0", elixirc_paths: elixirc_paths(Mix.env), compilers: [:phoenix, :gettext] ++ Mix.compilers, build_embedded: Mix.env == :prod, start_permanent: Mix.env == :prod, deps: deps] end
def application do [mod: {Hello, []}, applications: app_list(Mix.env) ] end def app_list do [:phoenix, :phoenix_html, :cowboy, :logger, :gettext] end def app_list(:test), do: [:hound | app_list] def applist(), do: app_list
defp elixirc_paths(:test), do: ["lib", "web", "test/support"] defp elixircpaths(), do: ["lib", "web"]
defp deps do [{:phoenix, "~> 1.1.2"}, {:httpoison, "~>0.8.1"}, {:hound, "~> 0.8"}, {:phoenix_html, "~> 2.3"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.9"}, {:cowboy, "~> 1.0"}] end end
i started phantomjs in another terminal using
sharathkumar@dkarnik1:/usr/local/bin$ phantomjs --wd
PhantomJS is launching GhostDriver...
[INFO - 2016-02-22T09:59:17.032Z] GhostDriver - Main - running on port 8910
In the same way i also started chromedriver using ./chromedriver
command but still i get the error.
Please help me resolve it. And also can you guide me through a right way to start selenium webdriver? Because no tutorial tells how to start a selenium webdriver. It might be simple but a beginner like me may find it helpful if you include it in the hound documentation.
Thanks
Hello,
As first mentioned in: #49 but now formally as its own issue.
Following this tutorial: https://lord.io/blog/2015/elixir-scraping/
And I'm getting this error:
With this mix.exs: