this.Action('click','.todo',3) //calls a click on the third element with class '.todo'
{String} - A lowercase event type. One of ['change', 'click', 'contextmenu', 'dblclick', 'keyup', 'keydown', 'keypress','mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'submit', 'focus', 'blur','drag', 'write'].
{String/HTMLElement} - An HTMLElement or a CSS selector.
{Number/Object} - If a number is provided, it uses it to select that number from the array of elements returned by doing a CSSQuery with selector. If an object is provided, it passes those options to the SyntheticEvent for creation. If nothing is provided, the number defaults to 0.
Calls Action using 'dblclick' as the first parameter.
{String/HTMLElement} -
{Object/Number} -
Drag
Drag(selector_or_element, options) -> undefined
Creates events that simulate a drag motion across the browser. The drag events are comprised of a mousedown from the from location, equal spaced mousemoves to the to location, and a mouseup at the to location. Drag is by default syncronous, but can be made asyncronous by providing a duration option.
A callback that gets called when the drag motion has completed. This is only
necessary with asyncronous drags. Typically, the callback can be provided by
next_callback();
duration
null
The length of time in seconds the drag takes place. By setting this
option, the events are dispatched in intervals, letting the browser update the
screen. Typically, you want to provide a callback to test the results of the
drag after completion.
from
null
The starting coordinates of the drag. This can be specified in three ways: first, as an
object like {x: 123, y: 321}; second, as a HTMLElement; third, as the string ID of
a HTMLElement. Providing an element or the id of an element, Drag will use the
center of the element as is starting position.
steps
100
The number of mousemoves called to represent the drag. This parameter is void if
duration is provided.
to
null
The ending coordinates of the drag. Use the to option the same
way as the from option.
Calls Action using 'focus' as the first parameter.
{String/HTMLElement} -
{Object/Number} -
init
init(name, tests) -> undefined
Creates a new functional test case. A test case is a collection of test functions and helpers.
new MVC.Test.Functional('TestCaseName',{
test_some_clicks : function(){
this.Click('#button')
}
})
{String} - The unique name of the test. Make sure no two tests have the same name.
{Object} - An object with test functions. Functions that begin with test_ will be run as tests. Functions that don't begin with test are converted to helper functions. Do not name helper functions the same name as the test provided helpers and assertions such as assert or assertEqual as your functions will override these functions.
Calls Action using 'keypress' as the first parameter. In browsers other that Firefox, keypress support built into the browser doesn't actually write text into the input element. To make up for this shortcoming, this method manually inserts text into the input element's value attribute.
{String/HTMLElement} -
{String} - character to be written to the passed element, '\b' causes a character to be deleted, '\n' simulates pressing enter
{Object} - a hash with the following properties:
Option
Default
Description
character
false
True to simulate pressing the alt key.
ctrlKey
false
True to simulate pressing the control key.
altKey
false
True to simulate pressing the alt key.
shiftKey
false
True to simulate pressing the shift key.
metaKey
false
True to simulate pressing the meta key.
keyCode
0
Used to simulate pressing other keys, this reference shows a list of keyCodes you can use.
Creates events that simulate writing into an input element. If a callback option is used in the second parameter, the event is asynchronous. Otherwise, it is synchronous.
// syntax 1: synchronous version
this.Write(input_params.element, 'Brian');
// syntax 2: asynchronous version
this.Write(input_params.element, {text: 'Brian', callback: this.next_callback()});
{String/HTMLElement} -
{Object/String} - If a string is passed, it is the text written in the passed input element. If a hash is passed it, it expects the following parameters:
Option
Default
Description
callback
null
A callback that gets called when the write has completed. This is only
necessary with asyncronous writes. Typically, the callback can be provided by
next_callback();
duration
null
The length of time in seconds the write takes place. By setting this
option, the events are dispatched in intervals, letting the browser update the
screen. Typically, you want to provide a callback to test the results of the
drag after completion.
text
null
The text to be written into the given input element.
'\b' - the backspace character is used to delete one character of text
'\n' - the newline character is used to simulate pressing enter