TucoTuco.DSL

Source

Summary

accept_alert(f)

Accept an alert that comes up

accept_prompt(text, f)

Accept a prompt and fill it in with the text given

alert_text()

Return the text contained in an alert

current_host()

Returns the host part of the current url

current_path()

Returns the path portion of the current url

current_port()

Returns the port part of the current url

current_query()

Returns the query portion of the current url

current_session()

Returns the name or pid of the current TucoTuco session

current_url()

Returns the current url as a string

dismiss_confirm(f)

Dismiss a confirmation dialog. This is the equivalent to clicking on what is usually the Cancel button

execute_async_javascript(script, arguments \\ [])

Executes javascript in the page. This executes the javascript asynchronously and returns when the callback is called which will be injected as the last argument to the function

execute_javascript(script, arguments \\ [])

Executes javascript in the page

go_back()

Send the browser backward in history

go_forward()

Send the browser forward in history

has_alert?()

True or false depending on if a prompt, alert or confirm dialog is currently open on the page

save_screenshot(file_path)

Saves a PNG screenshot at the path specified. Returns :ok if successful or {:error, reason} if there is an error

visit(url)

Send the browser to the specified url

Functions

accept_alert(f)

Accept an alert that comes up.

Note that alerts, prompts and dialogs will prevent interaction with the page whilst they are open so any actions that open one must be wrapped in an accept_alert, accept_prompt or dismiss_confirm call.

Example:

accept_alert fn ->
  click("Show Alert")
end
Source
accept_prompt(text, f)

Accept a prompt and fill it in with the text given.

Example:

accept_prompt "Elixir is Great", fn ->
  click_link("Prompt me")
end
Source
alert_text()

Return the text contained in an alert.

Example:

accept_alert fn ->
  click("Show Alert")
  assert "this is an alert" = alert_text
end
Source
current_host()

Returns the host part of the current url.

Source
current_path()

Returns the path portion of the current url.

Source
current_port()

Returns the port part of the current url.

Source
current_query()

Returns the query portion of the current url.

Source
current_session()

Returns the name or pid of the current TucoTuco session.

Source
current_url()

Returns the current url as a string.

Source
dismiss_confirm(f)

Dismiss a confirmation dialog. This is the equivalent to clicking on what is usually the Cancel button.

Example:

dismiss_confirm fn ->
  click("Show Confirmation")
end
Source
execute_async_javascript(script, arguments \\ [])

Executes javascript in the page. This executes the javascript asynchronously and returns when the callback is called which will be injected as the last argument to the function.

Source
execute_javascript(script, arguments \\ [])

Executes javascript in the page.

The arguments can be referred to in the script by referencing the Javascript array called arguments.

Return values can be:

* :null
* A number.
* A string.
* A WebDriver.Element struct.
* A tuple list (Javacript object.)
* A list of any of these.

Example:

```

assert "Hello World" == execute_javascript("return argument[0] + argument[1]", ["Hello","World"])

```

Source
go_back()

Send the browser backward in history.

Source
go_forward()

Send the browser forward in history.

Source
has_alert?()

True or false depending on if a prompt, alert or confirm dialog is currently open on the page.

Source
save_screenshot(file_path)

Saves a PNG screenshot at the path specified. Returns :ok if successful or {:error, reason} if there is an error.

Source
visit(url)

Send the browser to the specified url.

If a relative url is specified it will be prepended with the TucoTuco.app_root

Source