当前位置: 首页 > 知识库问答 >
问题:

如何使用猎犬和硒在长生不老药/凤凰中进行测试

邓子濯
2023-03-14

这是我的混音

defmodule HelloPhoenix.Mixfile do
use Mix.Project

def project do
[app: :hello_phoenix,
 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,
 aliases: aliases,
 deps: deps]
end

# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
     [mod: {HelloPhoenix, []},
     applications: app_list(Mix.env) ]
 end

    def app_list do
    [:phoenix, :phoenix_html, :cowboy, :logger, :gettext, :phoenix_ecto, :postgrex]
end

    def app_list(:test), do: [:hound | app_list]
def app_list(_),     do: app_list


  # Specifies which paths to compile per environment.
      defp elixirc_paths(:test), do: ["lib", "web", "test/support"]
  defp elixirc_paths(_),     do: ["lib", "web"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
[{:phoenix, "~> 1.1.4"},
 {:postgrex, ">= 0.0.0"},
 {:phoenix_ecto, "~> 2.0"},
 {:phoenix_html, "~> 2.4"},
 {:phoenix_live_reload, "~> 1.0", only: :dev},
 {:gettext, "~> 0.9"},
 {:cowboy, "~> 1.0"},
{:hound, "~> 0.8"}]
  end

  # Aliases are shortcut or tasks specific to the current project.
   # For example, to create, migrate and run the seeds file at once:
   #
   #     $ mix ecto.setup
   #
   # See the documentation for `Mix` for more info on aliases.
   defp aliases do
["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
 "ecto.reset": ["ecto.drop", "ecto.setup"]]
  end
 end

这是我的配置/配置。

# Define your application's host and port (defaults to "http://localhost:4001")
#config :hound, app_host: "http://localhost", app_port: 4000

# Start with selenium driver (default)
config :hound, driver: "selenium"

# Use Chrome with the default driver (selenium)
#config :hound, browser: "chrome"

# Start with default driver at port 1234 and use firefox
#config :hound, port: 1234, browser: "firefox"

# Start Hound for PhantomJs
#config :hound, driver: "phantomjs"

# Start Hound for ChromeDriver (default port 9515 assumed)
#config :hound, driver: "chrome_driver"

测试/sample_test

    defmodule HelloPhoenix.SampleTest do
  use HelloPhoenix.ConnCase

  # Import Hound helpers
  use Hound.Helpers

  # Start a Hound session
  hound_session
    IO.puts "hai"
  test "GET /" do
    navigate_to("http://localhost:4000")
    :timer.sleep(5000) # puts server to sleep
    assert page_source =~ "Welcome to Phoenix"
  end
end

配置/测试. exs

# We don't run a server during test. If one is required,
# you can enable the server option below.
config :hello_phoenix, HelloPhoenix.Endpoint,
  http: [port: 4000],
  server: true

启动Web驱动程序服务器(一次尝试所有这些)

>

  • java -jar 硒-服务器-独立-2.48.2.jar

    java-jar selenium-server-standalone-2.49.0.jar

    Java-jar selenium-server-standalone-2 . 52 . 0

    docker run-it-p 4444:4444 danielfrg/硒

    docker run--特权-p 4444:4444-p 5999:5999-d vvoyer/docker-selenium-firefox-chrome

    我每次运行应用程序时都会收到此错误:

    karthik@dkarnik2-Vostro-3558:~/5/hello_phoenix/hello_phoenix$ mix test
    hai
    ....10:46:52.543 [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
    
    
      1) test GET / (HelloPhoenix.SampleTest)
         test/sample_test.exs:10
         ** (exit) exited in: GenServer.call(Hound.SessionServer, {:change_session, #PID<0.394.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:544: GenServer.call/3
           test/sample_test.exs:8: HelloPhoenix.SampleTest.__ex_unit_setup_1/1
           test/sample_test.exs:1: HelloPhoenix.SampleTest.__ex_unit__/2
    
    
    
    Finished in 0.7 seconds (0.5s on load, 0.1s on tests)
    5 tests, 1 failure
    
    Randomized with seed 332515
    karthik@dkarnik2-Vostro-3558:~/5/hello_phoenix/hello_phoenix$
    
  • 暂时还没有答案

     类似资料:
    • 我在laravel 5.4项目上成功安装了npm安装包。这是我的package.json: {“private”:true,“scripts”:{“dev”:“node node_modules/cross env/dist/bin/cross-env.js node_env=development node_modules/webpack/bin/webpack.js--progress--hi

    • 插件更新到Spark2.0了吗?我不能使用插件 错误: 只要jdbc连接凤凰就可以了!

    • 一些基本信息如下: Hadoop2.7.1和NameNode HA enable hbase0.98.12 phoenix-4.6.0-hbase-0.98 执行sqlline.py localhost is error 执行sqlline.py localhost:nameservices/hbase is error

    • 注: 在testng xml中,如果我将parallel=更改为类或方法,那么它可以很好地运行测试,但它不是并行地一个接一个地运行测试。 如果我保持parallel=“tests”,那么它会并行运行,但它会在同一个VM中打开同一个浏览器三次,这是不正确的。 我的设置: 我设置了11个虚拟机,每个盒子上的每个浏览器都初始化了Selenium网格节点。我已经创建了testng xml,以便在每个框上运

    • 我是硒的新手,也是毛茸茸的测试。我看到Selenium IDE只允许固定的测试用例。但是模糊测试似乎是有帮助的。 如有任何帮助,我们将不胜感激。

    • 我想在Jenkins中运行Selenium Webdriver Maven测试。我遵循了教程:https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html和https://www.safaribooksonline.com/library/view/jenkins-the-definitive/978144931