robotx

dojo/robotx

See the dojo/robotx reference documentation for more information.

Properties

doc

Defined by: dojo/robotx

mouseWheelSize

Defined by: doh/robot

window

Defined by: dojo/robotx

Methods

initRobot(url)

Defined by dojo/robotx

Opens the application at the specified URL for testing, redirecting dojo to point to the application environment instead of the test environment.

Parameter Type Description
url String

URL to open. Any of the test's dojo.doc calls (e.g. dojo.byId()), and any dijit.registry calls (e.g. dijit.byId()) will point to elements and widgets inside this application.

keyDown(charOrCode,delay)

Defined by doh/robot

Holds down a single key, like SHIFT or 'a'.

Holds down a single key, like SHIFT or 'a'.

Parameter Type Description
charOrCode Integer

char/JS keyCode/dojo.keys.* constant for the key you want to hold down Warning: holding down a shifted key, like 'A', can have unpredictable results.

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all

Examples

Example 1

to hold down the 'a' key immediately, call robot.keyDown('a')

keyPress(charOrCode,delay,modifiers,asynchronous)

Defined by doh/robot

Types a key combination, like SHIFT-TAB.

Types a key combination, like SHIFT-TAB.

Parameter Type Description
charOrCode Integer

char/JS keyCode/dojo.keys.* constant for the key you want to press

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all
modifiers Object

JSON object that represents all of the modifier keys being pressed. It takes the following Boolean attributes:

  • shift
  • alt
  • ctrl
  • meta
asynchronous Boolean

If true, the delay happens asynchronously and immediately, outside of the browser's JavaScript thread and any previous calls. This is useful for interacting with the browser's modal dialogs.

Examples

Example 1

to press shift-tab immediately, call robot.keyPress(dojo.keys.TAB, 0, {shift: true})

keyUp(charOrCode,delay)

Defined by doh/robot

Releases a single key, like SHIFT or 'a'.

Releases a single key, like SHIFT or 'a'.

Parameter Type Description
charOrCode Integer

char/JS keyCode/dojo.keys.* constant for the key you want to release Warning: releasing a shifted key, like 'A', can have unpredictable results.

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all

Examples

Example 1

to release the 'a' key immediately, call robot.keyUp('a')

killRobot()

Defined by doh/robot

mouseClick(buttons,delay)

Defined by doh/robot

Convenience function to do a press/release. See robot.mousePress for more info.

Convenience function to do a press/release. See robot.mousePress for more info.

Parameter Type Description
buttons Object
delay Integer
Optional

mouseMove(x,y,delay,duration,absolute)

Defined by doh/robot

Moves the mouse to the specified x,y offset relative to the viewport.

Parameter Type Description
x Number

x offset relative to the viewport, in pixels, to move the mouse.

y Number

y offset relative to the viewport, in pixels, to move the mouse.

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all
duration Integer
Optional

Approximate time Robot will spend moving the mouse The default is 100ms. This also affects how many mousemove events will be generated, which is the log of the duration.

absolute Boolean

Boolean indicating whether the x and y values are absolute coordinates. If false, then mouseMove expects that the x,y will be relative to the window. (clientX/Y) If true, then mouseMove expects that the x,y will be absolute. (pageX/Y)

mouseMoveAt(node,delay,duration,offsetX,offsetY)

Defined by dojo/robot

Moves the mouse over the specified node at the specified relative x,y offset.

Moves the mouse over the specified node at the specified relative x,y offset. If you do not specify an offset, mouseMove will default to move to the middle of the node. Example: to move the mouse over a ComboBox's down arrow node, call doh.mouseMoveAt(dijit.byId('setvaluetest').downArrowNode);

Parameter Type Description
node String | DOMNode | Function

The id of the node, or the node itself, to move the mouse to. If you pass an id or a function that returns a node, the node will not be evaluated until the movement executes. This is useful if you need to move the mouse to an node that is not yet present.

delay Integer, optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left:true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all
duration Integer, optional

Approximate time Robot will spend moving the mouse The default is 100ms.

offsetX Number, optional

x offset relative to the node, in pixels, to move the mouse. The default is half the node's width.

offsetY Number, optional

y offset relative to the node, in pixels, to move the mouse. The default is half the node's height.

mouseMoveTo(point,delay,duration,absolute)

Defined by doh/robot

Move the mouse from the current position to the specified point. Delays reading contents point until queued command starts running. See mouseMove() for details.

Parameter Type Description
point Object

x, y position relative to viewport, or if absolute == true, to document

delay Integer
Optional
duration Integer
Optional
absolute Boolean

mousePress(buttons,delay)

Defined by doh/robot

Presses mouse buttons.

Presses the mouse buttons you pass as true. Example: to press the left mouse button, pass {left: true}. Mouse buttons you don't specify keep their previous pressed state.

Parameter Type Description
buttons Object

JSON object that represents all of the mouse buttons being pressed. It takes the following Boolean attributes:

  • left
  • middle
  • right
delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all

mouseRelease(buttons,delay)

Defined by doh/robot

Releases mouse buttons.

Releases the mouse buttons you pass as true. Example: to release the left mouse button, pass {left: true}. Mouse buttons you don't specify keep their previous pressed state. See robot.mousePress for more info.

Parameter Type Description
buttons Object
delay Integer
Optional

mouseWheel(wheelAmt,delay,duration)

Defined by doh/robot

Spins the mouse wheel.

Spins the wheel wheelAmt "notches." Negative wheelAmt scrolls up/away from the user. Positive wheelAmt scrolls down/toward the user. Note: this will all happen in one event. Warning: the size of one mouse wheel notch is an OS setting. You can access this size from robot.mouseWheelSize

Parameter Type Description
wheelAmt Number

Number of notches to spin the wheel. Negative wheelAmt scrolls up/away from the user. Positive wheelAmt scrolls down/toward the user.

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms: robot.mouseClick({left: true}, 100) // first call; wait 100ms robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all

duration Integer
Optional

Approximate time Robot will spend moving the mouse By default, the Robot will wheel the mouse as fast as possible.

scrollIntoView(node,delay)

Defined by dojo/robot

Scroll the passed node into view, if it is not.

Parameter Type Description
node String | DOMNode | Function

The id of the node, or the node itself, to move the mouse to. If you pass an id or a function that returns a node, the node will not be evaluated until the movement executes. This is useful if you need to move the mouse to an node that is not yet present.

delay Number, optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call.

sequence(f,delay,duration)

Defined by doh/robot

Defer an action by adding it to the robot's incrementally delayed queue of actions to execute.

Parameter Type Description
f Function

A function containing actions you want to defer. It can return a Promise to delay further actions.

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all
duration Integer
Optional

Delay to wait after firing.

setClipboard(data,format)

Defined by doh/robot

Set clipboard content.

Set data as clipboard content, overriding anything already there. The data will be put to the clipboard using the given format.

Parameter Type Description
data String

New clipboard content to set

format String
Optional

Set this to "text/html" to put richtext to the clipboard. Otherwise, data is treated as plaintext. By default, plaintext is used.

startRobot()

Defined by doh/robot

Returns: undefined

typeKeys(chars,delay,duration)

Defined by doh/robot

Types a string of characters in order, or types a dojo.keys.* constant.

Types a string of characters in order, or types a dojo.keys.* constant.

Parameter Type Description
chars String | Number

String of characters to type, or a dojo.keys.* constant

delay Integer
Optional

Delay, in milliseconds, to wait before firing. The delay is a delta with respect to the previous automation call. For example, the following code ends after 600ms:

robot.mouseClick({left: true}, 100) // first call; wait 100ms
robot.typeKeys("dij", 500) // 500ms AFTER previous call; 600ms in all
duration Integer
Optional

Time, in milliseconds, to spend pressing all of the keys. The default is (string length)*50 ms.

Examples

Example 1

robot.typeKeys("dijit.ed", 500);

waitForPageToLoad(submitActions)

Defined by dojo/robotx

Notifies DOH that the doh.robot is about to make a page change in the application it is driving, returning a doh.Deferred object the user should return in their runTest function as part of a DOH test.

Parameter Type Description
submitActions Function

The doh.robot will execute the actions the test passes into the submitActions argument (like clicking the submit button), expecting these actions to create a page change (like a form submit). After these actions execute and the resulting page loads, the next test will start.

Returns: instance

Examples

Example 1

runTest: function(){
    return waitForPageLoad(function(){ doh.robot.keyPress(keys.ENTER, 500); });
}

Events

© 2005–2015 The Dojo Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/robotx.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部