class

Marionette::Session

Inherits Marionette::Logger / Reference / Object

Constants

Log = ::Log.for("marionette.session")

Class methods

start(driver : WebDriver, type : Type, capabilities = {} of String => String, service = nil)

Start a new Session using the given driver and type. You can pass in any capabilities you want here, and they'll be merged with the browser's desired capabilities.

Source

Instance methods

accept_alert

Accept an active alert. For confirmation boxes this is the same as clicking the "Ok" button.

Source
actions

Creates a new ActionBuilder instance and passes it to the block. Given actions are not performed on block exit, so you will need to call ActionBuilder#perform eventually.

Source
active_element

Returns the element with focus, or the page Body if nothing has focus.

Source
alert_text

Returns the text of the active alert dialog.

Source
alert_value=(value)

Sets the text box content for alert dialogs that have one.

Source
all_cookies

Return all cookies collected so far as an Array(HTTP::Cookie).

Source
back

Go back in history.

Source
capabilities
Source
clear_actions

Clears actions that are already stored on the remote end.

Source
close

Close the current session.

Source
close_current_window

Close the current Window.

Source
close_window(window : Window)

Close the given Window.

Source
context

Get the current browser context.

NOTE: Available for Firefox only.

Source
context=(context : String)

Set the current browser context.

NOTE: Available for Firefox only.

Source
current_url

Get the URL of the current page.

Source
current_window

Return the current Window.

Source
debug

Enable and attach the Safari debugger.

NOTE: Available for Chrome/Chromium only.

Source
delete_all_cookies

Delete all collected cookies

Source
dismiss_alert

Dismiss an active alert. For confirmation boxes this is the same as clicking the "Cancel" button.

Source
driver
Source
execute(command, params = {} of String => String)

Execute an arbitrary command with the given permissions. See Commands for all available commands.

Source
execute_cdp_command(cmd : String, args = {} of String => String)

Execute a CDP (Chrome DevTools Protocol) command. See the API documentation for information on acceptable commands.

NOTE: Available for Chrome/Chromium only.

Source
execute_script(script, args = nil)

Execute arbitrary JavaScript in the context of the given document. Any args to be passed into the script should be provided as an array.

For now the result is returned as raw JSON.

Source
execute_script_async(script, args = nil)

Execute arbitrary JavaScript in the context of the given document. Any args to be passed into the script should be provided as an array.

This is an async process and does not return a result.

Source
find_element(selector, strategy : LocationStrategy = :css)

Find an element using the given selector. The strategy can be any LocationStrategy. Default is LocationStrategy::Css. Returns nil if no element with the given selector was found.

Source
find_element!(selector, strategy : LocationStrategy = :css)

Find an element using the given selector. The strategy can be any LocationStrategy. Default is LocationStrategy::Css. Raises an exception if no element with the given selector was found.

Source
find_element_child(element, selector, strategy : LocationStrategy = :css)

Find a child of the given element. Returns nil if no element with the given selector was found.

Source
find_element_child!(element, selector, strategy : LocationStrategy = :css)

Find a child of the given element. Raises an exception if no element with the given selector was found.

Source
find_element_children(element, selector, strategy : LocationStrategy = :css)

Find multiple children of the given element with the given selector and return them as an array.

Source
find_elements(selector, strategy : LocationStrategy = :css)

Find multiple elements with the given selector and return them as an array.

Source
forward

Go forward in history.

Source
full_page_screenshot

Takes a full screen screenshot and return it as a Base64 encoded PNG string.

NOTE: Available for Firefox only.

Source
implicit_wait(time : Time::Span)

Add an implicit wait that will occur before calls are made in a newly opened page.

Source
install_addon(path : String, temporary = false)

Install an addon from the given path. If temporary is set to true this addon will only be installed for the current session.

NOTE: Available for Firefox only.

Source
issue_message

Get the issue message for the current cast context.

NOTE: Available for Chrome/Chromium only.

Source
launch_app(app_id : String)

Launch a Chrome app using its id.

NOTE: Available for Chrome/Chromium only.

Source
leave_frame

Leave the current frame context and return to the default context.

Source
local?

Returns true if this is a local session.

Source
log(log_type : String)
Source
log_types
Source
network_conditions

Return the set network conditions as a NetworkConditions object. This will raise if network conditions haven't been set already.

NOTE: Available for Chrome/Chromium only.

Source
network_conditions=(conditions : NetworkConditions)

Set the network conditions.

NOTE: Available for Chrome/Chromium only.

Source
new_window(type : Window::Type = :window)

Create a new Window. The window will not be switched to automatically.

Source
orientation

Get the orientation of the current driver.

NOTE: only available on non-W3C compatible drivers.

Source
orientation=(origination : Orientation)

Set the orientation of the current driver.

NOTE: only available on non-W3C compatible drivers.

Source
page_load_timeout(time : Time::Span)

Add a timeout for page loads. Pages that take longer than the given amount of time to load will throw an Error::TimeoutError.

Source
page_source

Return the source of the given page. For most pages this will be HTML markup.

Source
perform_actions(debug_mouse_move = false, &)

Creates a new ActionBuilder instance and passes it to the block. Actions are performed immediately upon block exit.

Set debug_mouse_move to true to get visual indicators on screen when the mouse changes location.

Source
permissions

Get the currently set Safari permisisons.

NOTE: Available for Safari only.

Source
permissions=(perms : Hash(String, Bool))

Set Safari permissions.

NOTE: Available for Chrome/Chromium only.

Source
refresh

Refresh the current page.

Source
remote?

Returns true if this is a remote session.

Source
save_full_page_screenshot(path : String)

Take a fullscreen screenshot and save it to the given path as a PNG image.

NOTE: Available for Firefox only.

Source
save_screenshot(path, element_id = nil, scroll = true)

Take a screenshot and save it as a PNG at the given path. If scroll is set to true the element will be scrolled to before taking the screenshot.

Source
script_timeout(time : Time::Span)

Add a timeout for script execution. Scripts that take longer than the given amount of time to execute will throw as Error::TimeoutError.

Source
service
Source
service=(service : Service | Nil)
Source
service?
Source
set_permission(key : String, value : Bool)

Set a single Safari permission.

NOTE: Available for Chrome/Chromium only.

Source
sink=(sink_name : String)

Set the current casting sink.

NOTE: Available for Chrome/Chromium only.

Source
sinks

Get a list of sinks for casting.

NOTE: Available for Chrome/Chromium only.

Source
start_tab_mirroring(sink_name : String)

Start mirroring the current tab using the given sink.

NOTE: Available for Chrome/Chromium only.

Source
status

Return the status of the current driver as a JSON object.

Source
stop

Stops the current session by closing it and then closing the WebDriver process.

Source
stop_casting(sink_name : String)

Stop casting to the current sink.

NOTE: Available for Chrome/Chromium only.

Source
switch_to_frame(frame : Element)

Switch the context to the given frame or iframe element.

Source
switch_to_parent_frame

Switch the context to the parent of the given frame or iframe element.

Source
switch_to_window(handle : String)

Switch to a given Window using its handle.

Source
switch_to_window(window : Window)

Switch to a given Window.

Source
take_screenshot(element_id : String, scroll = true)

Take a screenshot of the element with the given element_id. If scroll is set to true the element will be scrolled to before taking the screenshot.

The PNG data is returned as a Base64 encoded string.

Source
take_screenshot

Take a screenshot of the current visible portion of the screen. The PNG is returned as a Base64 encoded string.

Source
title

Return the title of the current page.

Source
type
Source
uninstall_addon(id : String)

Uninstall an addon using its id.

NOTE: Available for Firefox only.

Source
w3c?
Source
wait_for_element(selector : String, strategy : LocationStrategy = :css, timeout = 3.seconds, poll_time = 50.milliseconds, &)

Wait the given amount of time for an element to be available. If no element is found an exception will be raised.

Source
wait_for_element(selector : String, strategy : LocationStrategy = :css, timeout = 3.seconds, poll_time = 50.milliseconds)

Wait the given amount of time for an element to be available. If no element is found an exception will be raised.

Source
wait_for_elements(selector : String, strategy : LocationStrategy = :css, timeout = 3.seconds, poll_time = 50.milliseconds, &)

Wait the given amount of time for elements to be available. If no element is found an exception will be raised.

Source
windows

Return an array of all opened Windows.

Source

Nested types