• Stars
    star
    1,362
  • Rank 34,494 (Top 0.7 %)
  • Language
    Elixir
  • License
    MIT License
  • Created almost 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Elixir library for writing integration tests and browser automation

Hound

For browser automation and writing integration tests in Elixir.

Source | Documentation

Build Status

Features

  • Can run multiple browser sessions simultaneously. See example.

  • Supports Selenium (Firefox, Chrome), ChromeDriver and PhantomJs.

  • Supports Javascript-heavy apps. Retries a few times before reporting error.

  • Implements the WebDriver Wire Protocol.

Internet Explorer may work under Selenium, but hasn't been tested.

Example

ExUnit example
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

Here's another simple browser-automation example.

Setup

Hound requires Elixir 1.0.4 or higher.

  • Add dependency to your mix project
{:hound, "~> 1.0"}
  • Start Hound in your test/test_helper.exs file before the ExUnit.start() line:
Application.ensure_all_started(:hound)
ExUnit.start()

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.

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:

config :hello_world_web, HelloWorldWeb.Endpoint,
  http: [port: 4001],
  server: true

Configure

To configure Hound, use your config/config.exs file or equivalent.

Example:

config :hound, driver: "phantomjs"

More examples here.

Usage

Add the following lines to your ExUnit test files.

# Import helpers
use Hound.Helpers

# Start hound session and destroy when tests are run
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.

Helpers

The documentation pages include examples under each function.

The docs are at http://hexdocs.pm/hound.

FAQ

Can I run multiple browser sessions simultaneously

Oh yeah ~! Here is an example.

If you are running PhantomJs, take a look at the Caveats section below.

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?

Yes. A separate session is started for each test process.

PhantomJs caveats

PhantomJs is extremely fast, but there are certain caveats. It uses Ghostdriver for its webdriver server, which currently has unimplemented features or open issues.

  • Cookie jar isn't separate for sessions - ariya/phantomjs#11417 Which means all sessions share the same cookies. Make sure you run delete_cookies() at the end of each test.
  • Isolated sessions were added to GhostDriver recently and are yet to land in a PhantomJs release.
  • Javascript alerts aren't yet supported - https://github.com/detro/ghostdriver/issues/20.

Running tests

You need a webdriver in order to run tests. We recommend phantomjs but any can be used by setting the WEBDRIVER environment variable as shown below:

$ phantomjs --wd
$ WEBDRIVER=phantomjs mix test

Maintainers

Customary proclamation...

Copyright © 2013-2015, Akash Manohar J, under the MIT License (basically, do whatever you want)

More Repositories

1

heroku-buildpack-elixir

Heroku Buildpack for Elixir with nitro boost
Shell
810
star
2

mogo-chat

Beautiful team chat app written in Elixir & Ember.js
JavaScript
740
star
3

ansible-elixir-stack

Ansible role to setup server with Elixir & Postgres to deploy apps
Python
295
star
4

arduino

A ruby library to talk to Arduino without having to burn programs repeatedly to the board
Ruby
248
star
5

Python-Arduino-Prototyping-API

Helps you to quickly prototype Arduino programs, without having to repeatedly load the program to the Arduino board
Python
148
star
6

mailgun

mailgun library for ruby
Ruby
118
star
7

rotor

Super-simple build system for Elixir
Elixir
83
star
8

mail-to-json

A MailGun.com clone in under 300 lines of Elixir
Elixir
45
star
9

elixir-users

Elixir users and meetups on a map
Ruby
39
star
10

heroku-buildpack-elixir-otp-builds

Erlang OTP build scripts for the Heroku Elixir Buildpack
Shell
37
star
11

coffee_rotor

Rotor plugin to compile CoffeeScript files
Elixir
17
star
12

realm

Database-independent model layer for Elixir with validations
Elixir
11
star
13

riak_pool

Provides pooled Riak connections for Elixir apps. Re-connects automatically upon disconnection.
Elixir
9
star
14

j

a simple command-line task manager written in ruby
Ruby
7
star
15

pixelart-editor

a pixel art editor using HTML DIVs for my HackerSchool application
CoffeeScript
6
star
16

ecto-riak-adapter

Elixir
6
star
17

wordpress-deploy

🔐 Secure and 🤑 budget-friendly Wordpress setup for your digital garden 🏡
PHP
6
star
18

billmebob

a simple rails3 invoice app
Ruby
5
star
19

elixir-examples

Elixir samples
Elixir
5
star
20

stylish

Erlang library to compile SCSS files
Erlang
5
star
21

github-create

a tool to help create github repos for projects directly from terminal
Ruby
4
star
22

ennio

Elixir
4
star
23

dot-files

all my dot files belong here
Vim Script
4
star
24

Prick

Prick.js lightweight web framework for node,js. Apologies for the bad name. I named it without knowing the other meaning of `Prick`
JavaScript
4
star
25

heroku-buildpack-elixir-test

Sample app to test and play with the Heroku Elixir Buildpack
Elixir
3
star
26

Dump-app

SMS dashboard for events
Ruby
3
star
27

Java-Arduino-Prototyping-API

Java Arduino API to prototype arduino based apps in java
Java
3
star
28

phoenix-deployment-notes

Dockerfile
2
star
29

Rtree.js

Implementation of RTree in javascript. Specific to 2D structures
JavaScript
2
star
30

EnnioLisp

A Scheme interpreter in Ruby
Ruby
2
star
31

VoicedOpen

support ticketing application that supports both Bushido and non-Bushido platforms
JavaScript
2
star
32

firebrick

Elixir
2
star
33

jump-ship

JavaScript
2
star
34

hackbadge

Hackathon stats, with drama and a climax
Ruby
2
star
35

duby-workouts

Sample Android applications using Duby - a work in progress
Java
2
star
36

Pong-In-Polycode

Pong game in Polycode - work in progress
Lua
2
star
37

rad-pike

Ruby
1
star
38

job_trends

Elixir
1
star
39

power-house

Elixir
1
star
40

rails_templates

Ruby
1
star
41

hackonday

site for hackonday
Ruby
1
star
42

get_mogo_chat

Landing page website for MogoChat
Elixir
1
star
43

quicktodo

a todo list app in rails.
Ruby
1
star
44

tic-tac-toe-coffeescript

Tic Tac Toe in coffeescript
JavaScript
1
star
45

rosalind

Elixir
1
star
46

kogo

Ruby
1
star
47

SICP-excercises

SICP excercises. Says it all
Racket
1
star
48

dot-emacs

my .emacs.d dir :)
Emacs Lisp
1
star
49

ShoutJam

source code for an SMS service I operated in Feb-2009
Python
1
star
50

take_a_look

A try a writing a simple ruby debugger
Ruby
1
star
51

HashNuke

1
star
52

airport_ride

airport_ride app
Ruby
1
star
53

stpvm

stpvm
JavaScript
1
star
54

elixir-for-breakfast

Elixir
1
star
55

hello-stage

Elixir
1
star
56

darkroom-mode

git mirror for https://bitbucket.org/phromo/darkroom-mode/ Distraction-free emacs writing mode
Emacs Lisp
1
star
57

brunch-bower-babel-starter

JavaScript
1
star
58

wire

Elixir websockets server for browser-based games
Elixir
1
star
59

htdp-solutions

My solutions to the exercises in the book "How To Design Programs"
Scheme
1
star
60

graphql-tryouts

GraphQL tryouts with Rails & Python apps along with schema-stitching
Ruby
1
star
61

meteorites-data-scripts

Scripts to add country info for meteorites dataset, using Geonames API
Ruby
1
star
62

hello_plug_sessions

sample app to play with plug sessions. configured with ets session store
Elixir
1
star