【发布时间】:2019-07-03 17:08:43
【问题描述】:
我开始了一个新项目并像这样配置它:
mix new example
cd example
我清空了 'lib/example.ex' 并在其中放置了以下代码:
Application.start :hound
defmodule Example do
use Hound.Helpers
def run do
Hound.start_session
navigate_to "http://akash.im"
IO.inspect page_title()
# Automatically invoked if the session owner process crashes
Hound.end_session
end
end
Example.run
这是https://github.com/HashNuke/hound/blob/master/notes/simple-browser-automation.md提供的示例代码
然后我通过brew install selenium-server-standalone(我在MacOS上)安装了Selenium服务器,通过brew services start selenium-server-standalone启动它,并将config :hound, driver: "selenium"添加到config/config.exs
我添加了Application.ensure_all_started(:hound) 作为test/test_helper.exs 的第一行。
最后,我将{:hound, "~> 1.0"} 添加到mix.exs 并运行mix test。那是我得到以下编译错误的时候:
localhost:example alex$ mix test
===> Compiling parse_trans
===> Compiling mimerl
===> Compiling metrics
===> Compiling unicode_util_compat
===> Compiling idna
==> jason
Compiling 8 files (.ex)
Generated jason app
==> ssl_verify_fun
Compiling 7 files (.erl)
Generated ssl_verify_fun app
===> Compiling certifi
===> Compiling hackney
==> hound
Compiling 37 files (.ex)
Generated hound app
==> example
Compiling 1 file (.ex)
== Compilation error in file lib/example.ex ==
** (ArgumentError) argument error
(stdlib) :ets.lookup(Hound.SessionServer, #PID<0.592.0>)
(hound) lib/hound/session_server.ex:19: Hound.SessionServer.current_session_id/1
(hound) lib/hound/session_server.ex:13: Hound.SessionServer.session_for_pid/2
lib/example.ex:7: Example.run/0
localhost:example alex$ mix test
Compiling 1 file (.ex)
== Compilation error in file lib/example.ex ==
** (ArgumentError) argument error
(stdlib) :ets.lookup(Hound.SessionServer, #PID<0.160.0>)
(hound) lib/hound/session_server.ex:19: Hound.SessionServer.current_session_id/1
(hound) lib/hound/session_server.ex:13: Hound.SessionServer.session_for_pid/2
lib/example.ex:7: Example.run/0
我是否在某处忘记了某个步骤或配置不正确?非常感谢任何帮助,谢谢!
【问题讨论】:
-
我想我会向您报告,我无法再与 Hound 合作。现在,我总是收到错误消息:
[error] GenServer Hound.SessionServer terminating ** (RuntimeError) could not create a new session: timeout, check webdriver is running。我尝试重新安装selenium-server-standalone,删除我的 elixir 项目并重新创建它,但没有运气。现在,我在回答中使用的示例都产生了相同的超时错误。 -
啊哈!我退出 Safari,然后重新启动 Safari,在 Safari 菜单栏中重新检查了
Develop/Allow Remote Automation,然后我的 Hound 测试再次运行。
标签: selenium elixir elixir-mix hound