TucoTuco
TucoTuco is a web testing suite for Elixir applications. To use it make sure the TucoTuco application is running by specifying it in your mix.exs file or doing:
:application.start :tuco_tuco
To use the methods it exposes in an ExUnit.Case just add this line at the top:
use TucoTuco.DSL
Example Test Case:
defmodule MyTest do
use ExUnit.Case
use TucoTuco.DSL
setup_all do
{:ok, _} = TucoTuco.start_session :test_browser, :test_session, :phantomjs
TucoTuco.app_root "http://localhost:3000"
:ok
end
teardown_all do
TucoTuco.stop
end
test "logging in" do
visit "/login"
fill_in "Login", "Stuart"
fill_in "Password", "my_secret_password"
click_button "Log In"
assert current_path = "/account"
assert Page.has_text? "Successfully logged in."
end
end
Summary
app_root() | Return the current application root url |
app_root(new_root) | Set the application root url to a new value |
current_session() | Return the pid or name of the current session |
current_session(new_session) | Set the current session to a different session. Will error if the specified session is not running |
max_retry_time() | Get the maximum number of retries setting for the application |
max_retry_time(value) | Set the maximum number of retries for the application. This defaults to 20. May be any integer > 0 |
retry_delay() | Get the application’s retry delay setting in milliseconds. This is the amount of time it sleeps before trying an operation again |
retry_delay(ms) | Set the application’s retry delay in milliseconds. This defaults to 50ms |
sessions() | Get a list of all the sessions that are running |
start(type, args) | Start the TucoTuco application |
start_session(browser_name, session_name, driver \\ :phantomjs) | Start a new session. If the browser with the name specified is not running this will start a new browser using the driver specified, and then start a session on that browser |
stop() | Stop all the browsers that are running and stop TucoTuco |
use_retry() | Is the application set to use retries? |
use_retry(value) | Set the use_retry option. When this is set the Page methods will retry a number of times. This is for situations where javascript may alter page contents and you need to wait for changes to occur |
Functions
Set the current session to a different session. Will error if the specified session is not running.
Get the maximum number of retries setting for the application
Set the maximum number of retries for the application. This defaults to 20. May be any integer > 0.
Get the application’s retry delay setting in milliseconds. This is the amount of time it sleeps before trying an operation again.
Set the application’s retry delay in milliseconds. This defaults to 50ms.
Start a new session. If the browser with the name specified is not running this will start a new browser using the driver specified, and then start a session on that browser.
Driver can be one of:
- :phantomjs
- :firefox
- :chrome