diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore index ff6a7e5..6cff63f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,30 @@ -/_build -/deps +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). *.ez + +# Ignore package tarball (built via "mix hex.build"). +hound-*.tar + +# Temporary files for e.g. tests. +/tmp/ + +# Misc. .DS_Store -doc/ screenshot-*.png diff --git a/README.md b/README.md index 9827ec1..c98e6be 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # Hound -For browser automation and writing integration tests in Elixir. - -Source | Documentation - [![Build Status](https://travis-ci.org/HashNuke/hound.png?branch=master)](https://travis-ci.org/HashNuke/hound) +[![Module Version](https://img.shields.io/hexpm/v/hound.svg)](https://hex.pm/packages/hound) +[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/hound/) +[![Total Download](https://img.shields.io/hexpm/dt/hound.svg)](https://hex.pm/packages/hound) +[![License](https://img.shields.io/hexpm/l/hound.svg)](https://github.com/HashNuke/hound/blob/master/LICENSE) +[![Last Updated](https://img.shields.io/github/last-commit/HashNuke/hound.svg)](https://github.com/HashNuke/hound/commits/master) + +For browser automation and writing integration tests in Elixir. ## Features @@ -16,72 +19,109 @@ For browser automation and writing integration tests in Elixir. * Implements the WebDriver Wire Protocol. -**Internet Explorer may work under Selenium, but hasn't been tested.** +**Note:** Internet Explorer may work under Selenium, but hasn't been tested. + +## Setup -#### Example +Hound requires Elixir 1.4 or higher. -##### ExUnit example +Add dependency to your mix project ```elixir -defmodule HoundTest do - use ExUnit.Case - use Hound.Helpers +{:hound, "~> 1.0"} +``` - hound_session() +Start Hound in your `test/test_helper.exs` file **before** the `ExUnit.start()` line: - test "the truth", meta do - navigate_to("http://example.com/guestbook.html") +```elixir +Application.ensure_all_started(:hound) +ExUnit.start() +``` - element = find_element(:name, "message") - fill_field(element, "Happy Birthday ~!") - submit_element(element) +When you run `mix test`, Hound is automatically started. __You'll need a webdriver server__ running, like Selenium Server or Chrome Driver. If you aren't sure what it is, then [read this](https://github.com/HashNuke/hound/wiki/Starting-a-webdriver-server). - assert page_title() == "Thank you" - end +### If you're using Phoenix -end -``` +Ensure the server is started when your tests are run. In `config/test.exs` change the `server` option of your endpoint config to `true`: -Here's another [simple browser-automation example](https://github.com/HashNuke/hound/blob/master/notes/simple-browser-automation.md). +```elixir +config :hello_world_web, HelloWorldWeb.Endpoint, + http: [port: 4001], + server: true +``` -## Setup +## Configure -Hound requires Elixir 1.0.4 or higher. +To configure Hound, use the project's `config/config.exs` file or equivalent (v0.14.0 and above). Here are some examples: -* Add dependency to your mix project +```elixir +# Start with selenium driver (default) +config :hound, driver: "selenium" +``` ```elixir +# Use Chrome with the default driver (selenium) +config :hound, driver: "chrome" +``` -{:hound, "~> 1.0"} +```elixir +# Start with default driver at port 1234 and use firefox +config :hound, port: 1234, browser: "firefox" ``` -* Start Hound in your `test/test_helper.exs` file **before** the `ExUnit.start()` line: +```elixir +# Start Hound for PhantomJs +config :hound, driver: "phantomjs" +``` ```elixir -Application.ensure_all_started(:hound) -ExUnit.start() +# Start Hound for ChromeDriver (default port 9515 assumed) +config :hound, driver: "chrome_driver" ``` -When you run `mix test`, Hound is automatically started. __You'll need a webdriver server__ running, like Selenium Server or Chrome Driver. If you aren't sure what it is, then [read this](https://github.com/HashNuke/hound/wiki/Starting-a-webdriver-server). +```elixir +# Use Chrome in headless mode with ChromeDriver (default port 9515 assumed) +config :hound, driver: "chrome_driver", browser: "chrome_headless" +``` -#### If you're using Phoenix -Ensure the server is started when your tests are run. In `config/test.exs` change the `server` option of your endpoint config to `true`: +```elixir +# Start Hound for remote PhantomJs server at port 5555 +config :hound, driver: "phantomjs", host: "http://example.com", port: 5555 +``` ```elixir -config :hello_world_web, HelloWorldWeb.Endpoint, - http: [port: 4001], - server: true +# Define your application's host and port (defaults to "http://localhost:4001") +config :hound, app_host: "http://localhost", app_port: 4001 ``` -## Configure +```elixir +# Define how long the application will wait between failed attempts (in miliseconds) +config :hound, retry_time: 500 +``` -To configure Hound, use your `config/config.exs` file or equivalent. +```elixir +# Define http client settings +config :hound, http: [recv_timeout: :infinity, proxy: ["socks5", "127.0.0.1", "9050"]] +``` -Example: +```elixir +# Define selenium hub settings +config :hound, + driver: "chrome_driver", + host: "http://localhost", + port: 32770, + path_prefix: "wd/hub/" +``` -```config :hound, driver: "phantomjs"``` +```elixir +# Set genserver timeout +config :hound, genserver_timeout: 480000 +``` -[More examples here](https://github.com/HashNuke/hound/blob/master/notes/configuring-hound.md). +```elixir +# Set default request retries +config :hound, retries: 3 +``` ## Usage @@ -97,6 +137,55 @@ hound_session() If you prefer to manually start and end sessions, use `Hound.start_session` and `Hound.end_session` in the setup and teardown blocks of your tests. +## Examples + +### Through ExUnit + +```elixir +defmodule HoundTest do + use ExUnit.Case + use Hound.Helpers + + hound_session() + + test "the truth", meta 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 +``` + +### Simple Browser Automation + +Make sure to configure Hound first, or you will get an error. + +```elixir +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 +``` + +More examples? [Checkout Hound's own test cases](https://github.com/HashNuke/hound/tree/master/test/helpers) ## Helpers @@ -112,25 +201,21 @@ The documentation pages include examples under each function. * [Session](http://hexdocs.pm/hound/Hound.Helpers.Session.html) * [Window](http://hexdocs.pm/hound/Hound.Helpers.Window.html) -The docs are at . - -### More examples? [Checkout Hound's own test cases](https://github.com/HashNuke/hound/tree/master/test/helpers) - ## FAQ -#### Can I run multiple browser sessions simultaneously +### Can I run multiple browser sessions simultaneously Oh yeah ~! [Here is an example](https://github.com/HashNuke/hound/blob/master/test/multiple_browser_session_test.exs). If you are running PhantomJs, take a look at the *Caveats* section below. -#### Can I run tests async? +### Can I run tests async? Yes. The number of tests you can run async at any point in time, depends on the number of sessions that your webdriver can maintain at a time. For Selenium Standalone, there seems to be a default limit of 15 sessions. You can set ExUnit's async option to limit the number of tests to run parallelly. -#### Will Hound guarantee an isolated session per test? +### Will Hound guarantee an isolated session per test? Yes. A separate session is started for each test process. @@ -157,4 +242,4 @@ You need a webdriver in order to run tests. We recommend `phantomjs` but any can ## Customary proclamation... -Copyright © 2013-2015, Akash Manohar J, under the MIT License (basically, do whatever you want) +Copyright © 2013-2021, Akash Manohar J, under the MIT License (basically, do whatever you want) diff --git a/lib/hound/browser.ex b/lib/hound/browser.ex index d62dad1..216853c 100644 --- a/lib/hound/browser.ex +++ b/lib/hound/browser.ex @@ -1,5 +1,7 @@ defmodule Hound.Browser do - @moduledoc "Low level functions to customize browser behavior" + @moduledoc """ + Low level functions to customize browser behavior. + """ @type t :: Hound.BrowserLike.t @@ -7,7 +9,9 @@ defmodule Hound.Browser do @callback default_capabilities(String.t) :: map - @doc "Creates capabilities for the browser and options, to be sent to the webdriver" + @doc """ + Creates capabilities for the browser and options, to be sent to the webdriver. + """ @spec make_capabilities(t, map | Keyword.t) :: map def make_capabilities(browser_name, opts \\ []) do browser = browser(browser_name) @@ -25,7 +29,9 @@ defmodule Hound.Browser do |> Map.merge(additional_capabilities) end - @doc "Returns a user agent string" + @doc """ + Returns a user agent string. + """ @spec user_agent(String.t | atom) :: String.t def user_agent(ua) when is_binary(ua), do: ua diff --git a/lib/hound/browsers/chrome_headless.ex b/lib/hound/browsers/chrome_headless.ex index 51b3aa6..0792295 100644 --- a/lib/hound/browsers/chrome_headless.ex +++ b/lib/hound/browsers/chrome_headless.ex @@ -6,6 +6,6 @@ defmodule Hound.Browser.ChromeHeadless do def default_user_agent, do: :chrome def default_capabilities(ua) do - %{chromeOptions: %{"args" => ["--user-agent=#{ua}", "--headless", "--disable-gpu"]}} + %{chromeOptions: %{"args" => ["--user-agent=#{ua}", "--headless", "--disable-gpu"]}} end end diff --git a/lib/hound/element.ex b/lib/hound/element.ex index 1b14d4b..5d7667a 100644 --- a/lib/hound/element.ex +++ b/lib/hound/element.ex @@ -1,6 +1,6 @@ defmodule Hound.Element do @moduledoc """ - A representation of a web element + A representation of a web element. """ defstruct uuid: nil @@ -11,14 +11,14 @@ defmodule Hound.Element do @type selector :: t | matcher @doc """ - Returns true if the argument is an Element + Returns true if the argument is an Element. """ @spec element?(any) :: boolean def element?(%__MODULE__{}), do: true def element?(_), do: false @doc """ - Returns an element from a driver element response + Returns an element from a driver element response. """ @spec from_response(map) :: t def from_response(element) when is_map(element) do diff --git a/lib/hound/matchers.ex b/lib/hound/matchers.ex index 09bc0e8..f27beb2 100644 --- a/lib/hound/matchers.ex +++ b/lib/hound/matchers.ex @@ -1,5 +1,7 @@ defmodule Hound.Matchers do - @moduledoc "Text and element matchers" + @moduledoc """ + Text and element matchers. + """ import Hound.Helpers.Page import Hound.Helpers.Element @@ -8,6 +10,7 @@ defmodule Hound.Matchers do Returns true if text is found on the page. visible_in_page?(~r/Paragraph/) + """ @spec visible_in_page?(Regex.t) :: boolean def visible_in_page?(pattern) do @@ -37,6 +40,7 @@ defmodule Hound.Matchers do element?(:class, "block") element?(:id, "foo") + """ @spec element?(Hound.Element.strategy, String.t) :: boolean def element?(strategy, selector) do diff --git a/lib/hound/metadata.ex b/lib/hound/metadata.ex index 4917446..8b20dde 100644 --- a/lib/hound/metadata.ex +++ b/lib/hound/metadata.ex @@ -1,6 +1,7 @@ defmodule Hound.Metadata do @moduledoc """ Metadata allows to pass and extract custom data through. + This can be useful if you need to identify sessions. The keys and values must be serializable using `:erlang.term_to_binary/1`. @@ -50,6 +51,7 @@ defmodule Hound.Metadata do @doc """ Extracts and parses the metadata contained in a user agent string. + If the user agent does not contain any metadata, an empty map is returned. """ @spec parse(String.t) :: %{String.t => String.t} diff --git a/lib/hound/response_parser.ex b/lib/hound/response_parser.ex index 3ca06d9..79d6960 100644 --- a/lib/hound/response_parser.ex +++ b/lib/hound/response_parser.ex @@ -1,7 +1,7 @@ defmodule Hound.ResponseParser do @moduledoc """ Defines a behaviour for parsing driver responses - and provides a default implementation of the behaviour + and provides a default implementation of the behaviour. """ require Logger @@ -56,14 +56,14 @@ defmodule Hound.ResponseParser do def handle_response(_mod, _path, _code, _body), do: :error @doc """ - Default implementation to check if the message is a warning + Default implementation to check if the message is a warning. """ def warning?(message) do Regex.match?(~r/#{Regex.escape("not clickable")}/, message) end @doc """ - Decodes a response body + Decodes a response body. """ def decode_content([]), do: Map.new def decode_content(content), do: Jason.decode(content) @@ -71,7 +71,7 @@ defmodule Hound.ResponseParser do defmacro __before_compile__(_env) do quote do @doc """ - Fallback case if we did not match the message in the using module + Fallback case if we did not match the message in the using module. """ def handle_error(response) do case response do diff --git a/lib/hound/session.ex b/lib/hound/session.ex index 7bf24fe..7665cb1 100644 --- a/lib/hound/session.ex +++ b/lib/hound/session.ex @@ -1,23 +1,33 @@ defmodule Hound.Session do - @moduledoc "Low-level session functions internally used by Hound, to work with drivers. See Hound.Helpers.Session for session helpers" + @moduledoc """ + Low-level session functions internally used by Hound, to work with drivers. + + See Hound.Helpers.Session for session helpers. + """ import Hound.RequestUtils - @doc "Get server's current status" + @doc """ + Get server's current status. + """ @spec server_status() :: map def server_status() do make_req(:get, "status") end - @doc "Get list of active sessions" + @doc """ + Get list of active sessions. + """ @spec active_sessions() :: map def active_sessions() do make_req(:get, "sessions") end - @doc "Creates a session associated with the current pid" + @doc """ + Creates a session associated with the current pid. + """ @spec create_session(Hound.Browser.t, map | Keyword.t) :: {:ok, String.t} def create_session(browser, opts) do capabilities = make_capabilities(browser, opts) @@ -29,7 +39,9 @@ defmodule Hound.Session do make_req(:post, "session", params) end - @doc "Make capabilities for session" + @doc """ + Make capabilities for session. + """ @spec make_capabilities(Hound.Browser.t, map | Keyword.t) :: map def make_capabilities(browser, opts \\ []) do browser = opts[:browser] || browser @@ -46,35 +58,45 @@ defmodule Hound.Session do |> Map.merge(opts[:driver] || %{}) end - @doc "Get capabilities of a particular session" + @doc """ + Get capabilities of a particular session. + """ @spec session_info(String.t) :: map def session_info(session_id) do make_req(:get, "session/#{session_id}") end - @doc "Destroy a session" + @doc """ + Destroy a session. + """ @spec destroy_session(String.t) :: :ok def destroy_session(session_id) do make_req(:delete, "session/#{session_id}") end - @doc "Set the timeout for a particular type of operation" + @doc """ + Set the timeout for a particular type of operation. + """ @spec set_timeout(String.t, String.t, non_neg_integer) :: :ok def set_timeout(session_id, operation, time) do make_req(:post, "session/#{session_id}/timeouts", %{type: operation, ms: time}) end - @doc "Get the session log for a particular log type" + @doc """ + Get the session log for a particular log type. + """ @spec fetch_log(String.t, String.t) :: :ok def fetch_log(session_id, logtype) do make_req(:post, "session/#{session_id}/log", %{type: logtype}) end - @doc "Get a list of all supported log types" + @doc """ + Get a list of all supported log types. + """ @spec fetch_log_types(String.t) :: :ok def fetch_log_types(session_id) do make_req(:get, "session/#{session_id}/log/types") diff --git a/mix.exs b/mix.exs index 4831a49..9ec4d58 100644 --- a/mix.exs +++ b/mix.exs @@ -1,49 +1,52 @@ defmodule Hound.Mixfile do use Mix.Project + @source_url "https://github.com/HashNuke/hound" @version "1.1.1" def project do - [ app: :hound, + [ + app: :hound, version: @version, - elixir: ">= 1.4.0", - description: "Webdriver library for integration testing and browser automation", - source_url: "https://github.com/HashNuke/hound", + elixir: "~> 1.4", + source_url: @source_url, deps: deps(), package: package(), - docs: [source_ref: "#{@version}", extras: ["README.md"], main: "readme"] + docs: docs() ] end - def application do [ extra_applications: [:logger], - mod: {Hound, []}, - description: 'Integration testing and browser automation library', + mod: {Hound, []} ] end - defp deps do [ {:hackney, "~> 1.5"}, - {:jason, "~> 1.1"}, - {:earmark, "~> 1.2", only: :dev}, - {:ex_doc, "~> 0.16", only: :dev} + {:jason, "~> 1.1"}, + {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} ] end - defp package do [ + description: "Webdriver library for integration testing and browser automation", maintainers: ["Akash Manohar J", "Daniel Perez"], licenses: ["MIT"], - links: %{ - "GitHub" => "https://github.com/HashNuke/hound", - "Docs" => "http://hexdocs.pm/hound/" - } + links: %{"GitHub" => @source_url} ] end + defp docs do + [ + extras: ["README.md"], + main: "readme", + source_url: @source_url, + source_ref: "#{@version}", + formatters: ["html"] + ] + end end diff --git a/mix.lock b/mix.lock index b85a05f..46ff9cc 100644 --- a/mix.lock +++ b/mix.lock @@ -1,15 +1,17 @@ %{ "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], [], "hexpm", "fdc6066ceeccb3aa14049ab6edf0b9af3b64ae1b0db2a92d5c52146f373bbb1c"}, "earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm", "000aaeff08919e95e7aea13e4af7b2b9734577b3e6a7c50ee31ee88cab6ec4fb"}, - "ex_doc": {:hex, :ex_doc, "0.19.3", "3c7b0f02851f5fc13b040e8e925051452e41248f685e40250d7e40b07b9f8c10", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0e11d67e662142fc3945b0ee410c73c8c956717fbeae4ad954b418747c734973"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, + "ex_doc": {:hex, :ex_doc, "0.24.0", "2df14354835afaabdf87cb2971ea9485d8a36ff590e4b6c250b4f60c8fdf9143", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "a0f4bcff21ceebea48414e49885d2a3e542200f76a2facf3f8faa54935eeb721"}, "hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "5.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e38f4a7937b6dfc5fa87403ece26b1826bc81838f09ac57fabf2f7a9885fe818"}, "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fc1a2f7340c422650504b1662f28fdf381f34cbd30664e8491744e52c9511d40"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, - "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5fbc8e549aa9afeea2847c0769e3970537ed302f93a23ac612602e805d9d1e7f"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "adf0218695e22caeda2820eaba703fa46c91820d53813a2223413da3ef4ba515"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm", "7a4c8e1115a2732a67d7624e28cf6c9f30c66711a9e92928e745c255887ba465"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm", "5c040b8469c1ff1b10093d3186e2e10dbe483cd73d79ec017993fb3985b8a9b3"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm", "4f8805eb5c8a939cf2359367cb651a3180b27dfb48444846be2613d79355d65e"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], [], "hexpm", "da1d9bef8a092cc7e1e51f1298037a5ddfb0f657fe862dfe7ba4c5807b551c29"}, } diff --git a/notes/configuring-hound.md b/notes/configuring-hound.md deleted file mode 100644 index 81a7421..0000000 --- a/notes/configuring-hound.md +++ /dev/null @@ -1,72 +0,0 @@ -## Configuring Hound - -To configure Hound, use the project's `config/config.exs` file or equivalent (v0.14.0 and above). Here are some examples: - -```elixir -# Start with selenium driver (default) -config :hound, driver: "selenium" -``` - -```elixir -# Use Chrome with the default driver (selenium) -config :hound, driver: "chrome" -``` - -```elixir -# Start with default driver at port 1234 and use firefox -config :hound, port: 1234, browser: "firefox" -``` - -```elixir -# Start Hound for PhantomJs -config :hound, driver: "phantomjs" -``` - -```elixir -# Start Hound for ChromeDriver (default port 9515 assumed) -config :hound, driver: "chrome_driver" -``` - -```elixir -# Use Chrome in headless mode with ChromeDriver (default port 9515 assumed) -config :hound, driver: "chrome_driver", browser: "chrome_headless" -``` - -```elixir -# Start Hound for remote PhantomJs server at port 5555 -config :hound, driver: "phantomjs", host: "http://example.com", port: 5555 -``` - -```elixir -# Define your application's host and port (defaults to "http://localhost:4001") -config :hound, app_host: "http://localhost", app_port: 4001 -``` - -```elixir -# Define how long the application will wait between failed attempts (in miliseconds) -config :hound, retry_time: 500 -``` - -```elixir -# Define http client settings -config :hound, http: [recv_timeout: :infinity, proxy: ["socks5", "127.0.0.1", "9050"]] -``` - -```elixir -# Define selenium hub settings -config :hound, - driver: "chrome_driver", - host: "http://localhost", - port: 32770, - path_prefix: "wd/hub/" -``` - -```elixir -# Set genserver timeout -config :hound, genserver_timeout: 480000 -``` - -```elixir -# Set default request retries -config :hound, retries: 3 -``` \ No newline at end of file diff --git a/notes/simple-browser-automation.md b/notes/simple-browser-automation.md deleted file mode 100644 index 23fe542..0000000 --- a/notes/simple-browser-automation.md +++ /dev/null @@ -1,23 +0,0 @@ -Make sure to [configure Hound](https://github.com/HashNuke/hound/blob/master/notes/configuring-hound.md) first, or you will get an error. - -## Simple browser automation using Hound - -```elixir -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 -```