Script Methods
MarathonITE script methods are defined in playback.rb and provide the interface between Marathon runtime and Ruby scripts. You can use these methods in your test scripts.
Some methods are only marker methods. These methods do not perform any action, but MarathonITE internally uses them to identify some added functionality. For example, use_data_file is a marker method that tells MarathonITE to execute the script as a data driven test.
Object Identification
MarathonITE identifies components by using the name. if the component is a composite component (like list, table etc.) an extra componentInfo parameter is used. For example, in the following call:
click('list', 'List Item 1')
list is the name of the object and 'List Item 1' identifies a particular item from that list.
Methods
The following methods are available for MarathonITE test scripts. Some of them are generated in your scripts while recording a test. You can use them in your test scripts.
accept_checklist
accept_checklist(filename)
Show and accept input from the given checklist
assert_content
assert_content(componentName, content, componentInfo=nil)
asserts the content of a composite component (like table) matches the given content.
You can ignore comparing some of the cells by providing nil for those
entries
assert_equals
assert_equals(expected, actual, message = nil)
Assert that expected and actual are equal
a failure continues the test
assert_false
assert_false(actual, message = nil)
Assert that actual evaluates to false
a failure continues the test
assert_p
assert_p(component, property, value, componentInfo=nil)
assert property: assert that a property has the given value
assert_true
assert_true(actual, message = nil)
Assert that actual evaluates to true
a failure continues the test
click
click(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)
Click a component. This call generates a left mouse click.
Parameters are all optional and if exists should be given in the order shown below:
clickCount: number of clicks
position: x and y coordinates relative to the component
Modifiers: Can be any combination of Alt, Ctrl, Command, Shift separated by '+'
componentInfo: Select a cell component in a table, or a item in a list
close
close()
Pop the window out of the stack. The context is changed to the window below the stack. The next operation takes place only when that Window is focused or a new Window call is made.
component_capture
component_capture(fileName, windowName, componentName)
Capture an image of the specified component and save it to the specified file.
From MarathonV4, same as screen_capture
description
description(desc, type = 'text')
Provide meta data to the test script
type can be 'markdown', 'text' or 'html'
doubleclick
doubleclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil)
Double click a component. This call generates a left mouse click.
Parameters are all optional and if exists should be given in the order shown below:
position: x and y coordinates relative to the component
Modifiers: Can be any combination of Alt, Ctrl, Command, Shift separated by '+'
componentInfo: Select a cell component in a table, or a item in a list
drag
drag(componentName, startx, starty, endx, endy, o1 = nil, o2 = nil)
Drags the mouse pointer
The parameters o1, o2 represent the modifiers and the componentInfo. If both are given, the modifiers should precede componentInfo parameter.
drag_and_drop
drag_and_drop(source, sourceinfo, target, targetinfo, action)
Perform a drag and drop operation
source and sourceinfo: represents the source component
target and targetinfo: represents the target component
action: can either be 'copy' or 'move'
driver
driver()
Returns the webdriver instance
dump_components
dump_components()
Get a list of all visible components in the current window
error
error(message)
Fails the test case with the given message
The test script aborts after the call to error.
fail
fail(message)
Fail the test case with the given message
The test script continues running after the call to fail.
feature
feature(s)
Provide meta data to the test script
features
features(s, *others)
Provide meta data to the test script
files_equal
files_equal(path1, path2)
Compare the contents of two files
Returns true or false
get_component
get_component(componentName, componentInfo=nil)
Get the component represented by the given name
Marathon looks into the object repository to find the recognition properties
and then finds the component and returns the corresponding webelement. The
component should be visible, else an exception is thrown.
get_component_css
get_component_css(componentName, componentInfo=nil)
Get the CSS representation of the component
Marathon looks into the object repository to find the recognition properties
and then returns the CSS required to fetch the component
get_component_names
get_component_names()
Returns list of all names from the object repository for the current context
get_frame_objects
get_frame_objects()
Get the available frames (same as get_frames)
get_frames
get_frames()
Gets the available frames
get_named_components
get_named_components()
Returns a Hash of name and CSS for all the components in the current context
get_p
get_p(component, property, componentInfo=nil)
Get a property for the given component. Note that what is returned is a String representation of the property
get_po
get_po(component, property, componentInfo=nil)
Get a property for the given component. Note that what is returned is a String representation of the property
get_window
get_window()
Gets the title of the current window
get_window_object
get_window_object()
Gets the current window
hover
hover(componentName, delay = 500, componentInfo = nil)
Moves the mouse pointer to the middle of the component and waits for delay
milliseconds.
image_compare
image_compare(path1, path2, differencesInPercent=0)
Compare two images defined by their paths
Returns true or false
issue
issue(s)
Provide meta data to the test script
issues
issues(s, *others)
Provide meta data to the test script
keystroke
keystroke(componentName, keysequence, componentInfo=nil)
Send the given keysequence to the application. Keysequence are of the form
modifier+keystroke. The modifier is optional. If the given keysequence is a single character like 'A' - the corresponding keystroke (Shift+A) is sent to the application.
marathon_help
marathon_help()
mouse_down
mouse_down(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)
mouse_pressed
mouse_pressed(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)
Send a mouse pressed to the component
mouse_released
mouse_released(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)
Send a mouse released to the component
mouse_up
mouse_up(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)
name
name(arg)
Provide meta data to the test script
require_fixture
require_fixture(s)
Specifies the fixture required for executing the test script
rightclick
rightclick(componentName, o1 = nil, o2 = nil, o3 = nil, o4 = nil, o5 = nil)
Generate a right click event.
Parameters are all optional and if exists should be given in the order shown below: clickCount: number of clicks position: x and y coordinates relative to the component Modifiers: Can be any combination of Alt, Ctrl, Command, Shift separated by '+' componentInfo: Select a cell component in a table, or a item in a list
screen_capture
screen_capture(fileName)
Capture an image of the current screen and save it to the specified file.
select
select(componentName, text, componentInfo=nil)
Select a given component and set the state corresponding to the given text.
The state of a component differs from component to another component. For text fields it is the entered text, for a list it is selected items.
Marathon records the select when you perform actions on the application.
select_menu
select_menu(menuitems, keystroke=nil)
Select a given menu item. Menu items are separated by '>>' If a keystroke is given - the given keystroke is used to activate the menu.
set_no_fail_on_exit
set_no_fail_on_exit(b)
By default if the AUT exits, Marathon records that as an error. This flags turns off that behavior
Use the call close to the operation that exits the application
severity
severity(arg)
Provide meta data to the test script
severity can be one of blocker, critical, normal, minor, trivial
show_checklist
show_checklist(filename)
Display the contents from a filled checklist
sleep
sleep(seconds)
Sleep for the given number of seconds
stories
stories(s, *others)
Provide meta data to the test script
story
story(s)
Provide meta data to the test script
suite
suite(arg)
Provide meta data to the test script
use_data_file
use_data_file(filename)
Marker method used to identify data driven test
use_native_events
use_native_events()
Marker method: should be used before require_fixture to execute the test
using native events
wait_p
wait_p(component, property, value, componentInfo=nil)
wait property: Waits till a property has the given value
window
window(windowTitle, timeout = 0)
Waits for a window to appear and changes the context to that window. used by with_window call.
The timeout parameter is ignored
window_capture
window_capture(fileName, windowName)
Capture an image of the specified window and save it to the specified file.
From MarathonV4, same as screen_capture
window_changed
window_changed(state)
Posts a window change event. Used to reposition or change the size of the window
The state parameter is of the format x:y:w:h where (x,y) denotes the new position and (w,h) defines the size.
window_closed
window_closed(windowTitle)
Posts a window closed event to the window identified by the windowTitle parameter
with_data
with_data(filename) { || ... }
Execute the given block of code with data from the given file
Each column of the current row is set to a variable that can be accessed in the code block
with_frame
with_frame(windowTitle, timeout = 0) { || ... }
Wait for a internal frame to appear and execute the given block in that context.
The timeout parameter is ignored
with_window
with_window(windowTitle, timeout = 0) { || ... }
Waits for a window to appear and then executes the block given in that context.
The timeout parameter is ignored.