class Marionette::Session
- Marionette::Session
- Reference
- Object
Included Modules
Defined in:
Constant Summary
-
Log =
::Log.for("marionette.session")
Class Method Summary
Instance Method Summary
-
#accept_alert
Accept an active alert.
-
#actions(&)
Creates a new
ActionBuilder
instance and passes it to the block. -
#active_element
Returns the element with focus, or the page Body if nothing has focus.
-
#alert_text
Returns the text of the active alert dialog.
-
#alert_value=(value)
Sets the text box content for alert dialogs that have one.
-
#all_cookies
Return all cookies collected so far as an
Array(HTTP::Cookie)
. -
#back
Go back in history.
- #capabilities : Hash(String, JSON::Any)
-
#clear_actions
Clears actions that are already stored on the remote end.
-
#close
Close the current session.
-
#close_current_window
Close the current
Window
. -
#close_window(window : Window)
Close the given
Window
. -
#context
Get the current browser context.
-
#context=(context : String)
Set the current browser context.
-
#current_url
Get the URL of the current page.
-
#current_window
Return the current
Window
. -
#debug
Enable and attach the Safari debugger.
-
#delete_all_cookies
Delete all collected cookies
-
#delete_cookie(name : String)
Delete the cookie with the specified name.
-
#dismiss_alert
Dismiss an active alert.
- #driver : WebDriver
-
#execute(command, params = {} of String => String)
Execute an arbitrary command with the given permissions.
-
#execute_cdp_command(cmd : String, args = {} of String => String)
Execute a CDP (Chrome DevTools Protocol) command.
-
#execute_script(script, args = nil)
Execute arbitrary JavaScript in the context of the given document.
-
#execute_script_async(script, args = nil)
Execute arbitrary JavaScript in the context of the given document.
-
#find_element(selector, strategy : LocationStrategy = :css)
Find an element using the given
selector
. -
#find_element!(selector, strategy : LocationStrategy = :css)
Find an element using the given
selector
. -
#find_element_child(element, selector, strategy : LocationStrategy = :css)
Find a child of the given element.
-
#find_element_child!(element, selector, strategy : LocationStrategy = :css)
Find a child of the given element.
-
#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. -
#find_elements(selector, strategy : LocationStrategy = :css)
Find multiple elements with the given selector and return them as an array.
-
#forward
Go forward in history.
-
#full_page_screenshot
Takes a full screen screenshot and return it as a Base64 encoded PNG string.
-
#get_cookie(cookie : HTTP::Cookie)
Get a browser cookie using an
HTTP::Cookie
instance. -
#get_cookie(name : String)
Get the cookie with the specified name.
- #id : String
-
#implicit_wait(time : Time::Span)
Add an implicit wait that will occur before calls are made in a newly opened page.
-
#install_addon(path : String, temporary = false)
Install an addon from the given path.
-
#issue_message
Get the issue message for the current cast context.
-
#launch_app(app_id : String)
Launch a Chrome app using its
#id
. -
#leave_frame
Leave the current frame context and return to the default context.
-
#local?
Returns true if this is a local session.
- #log(log_type : String)
- #log_types
-
#navigate(to url : String | URI)
Go to the given URL.
-
#network_conditions
Return the set network conditions as a
NetworkConditions
object. -
#network_conditions=(conditions : NetworkConditions)
Set the network conditions.
-
#new_window(type : Window::Type = :window)
Create a new
Window
. -
#orientation
Get the orientation of the current driver.
-
#orientation=(origination : Orientation)
Set the orientation of the current driver.
-
#page_load_timeout(time : Time::Span)
Add a timeout for page loads.
-
#page_source
Return the source of the given page.
-
#perform_actions(debug_mouse_move = false, &)
Creates a new
ActionBuilder
instance and passes it to the block. -
#permissions
Get the currently set Safari permisisons.
-
#permissions=(perms : Hash(String, Bool))
Set Safari permissions.
-
#refresh
Refresh the current page.
-
#remote?
Returns true if this is a remote session.
-
#save_full_page_screenshot(path : String)
Take a fullscreen screenshot and save it to the given
path
as a PNG image. -
#save_screenshot(path, element_id = nil, scroll = true)
Take a screenshot and save it as a PNG at the given
path
. -
#script_timeout(time : Time::Span)
Add a timeout for script execution.
- #service : Service?
- #service=(service : Service?)
- #service? : Service | Nil?
-
#set_permission(key : String, value : Bool)
Set a single Safari permission.
-
#sink=(sink_name : String)
Set the current casting sink.
-
#sinks
Get a list of sinks for casting.
-
#start_tab_mirroring(sink_name : String)
Start mirroring the current tab using the given sink.
-
#status
Return the status of the current driver as a JSON object.
-
#stop
Stops the current session by closing it and then closing the WebDriver process.
-
#stop_casting(sink_name : String)
Stop casting to the current sink.
-
#switch_to_frame(frame : Element)
Switch the context to the given
frame
oriframe
element. -
#switch_to_parent_frame
Switch the context to the parent of the given
frame
oriframe
element. -
#switch_to_window(handle : String)
Switch to a given
Window
using its handle. -
#switch_to_window(window : Window)
Switch to a given
Window
. -
#take_screenshot(element_id : String, scroll = true)
Take a screenshot of the element with the given
element_id
. -
#take_screenshot
Take a screenshot of the current visible portion of the screen.
-
#title
Return the title of the current page.
- #type : Type
-
#uninstall_addon(id : String)
Uninstall an addon using its
#id
. - #w3c? : Bool
-
#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.
-
#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.
-
#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.
-
#windows
Return an array of all opened
Window
s.
Class Method Detail
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.
Instance Method Detail
Accept an active alert. For confirmation boxes this is the same as clicking the "Ok" button.
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.
Dismiss an active alert. For confirmation boxes this is the same as clicking the "Cancel" button.
Execute a CDP (Chrome DevTools Protocol) command. See the API documentation for information on acceptable commands.
NOTE Available for Chrome/Chromium only.
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.
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.
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.
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.
Find a child of the given element. Returns nil
if no element with the given
selector was found.
Find a child of the given element. Raises an exception if no element with the given selector was found.
Find multiple children of the given element
with the given selector and
return them as an array.
Find multiple elements with the given selector and return them as an array.
Takes a full screen screenshot and return it as a Base64 encoded PNG string.
NOTE Available for Firefox only.
Get the cookie with the specified name. Returns nil
if no cookie was found.
Add an implicit wait that will occur before calls are made in a newly opened page.
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.
Get the issue message for the current cast context.
NOTE Available for Chrome/Chromium only.
Launch a Chrome app using its #id
.
NOTE Available for Chrome/Chromium only.
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.
Set the network conditions.
NOTE Available for Chrome/Chromium only.
Get the orientation of the current driver.
NOTE only available on non-W3C compatible drivers.
Set the orientation of the current driver.
NOTE only available on non-W3C compatible drivers.
Add a timeout for page loads. Pages that take longer than the given amount of time to load
will throw an Error::TimeoutError
.
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.
Set Safari permissions.
NOTE Available for Chrome/Chromium only.
Take a fullscreen screenshot and save it to the
given path
as a PNG image.
NOTE Available for Firefox only.
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.
Add a timeout for script execution. Scripts that take longer than the given amount
of time to execute will throw as Error::TimeoutError
.
Set a single Safari permission.
NOTE Available for Chrome/Chromium only.
Set the current casting sink.
NOTE Available for Chrome/Chromium only.
Start mirroring the current tab using the given sink.
NOTE Available for Chrome/Chromium only.
Stop casting to the current sink.
NOTE Available for Chrome/Chromium only.
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.
Take a screenshot of the current visible portion of the screen. The PNG is returned as a Base64 encoded string.
Uninstall an addon using its #id
.
NOTE Available for Firefox only.
Wait the given amount of time for an element to be available. If no element is found an exception will be raised.
Wait the given amount of time for an element to be available. If no element is found an exception will be raised.
Wait the given amount of time for elements to be available. If no element is found an exception will be raised.