Keyword Documentation - Thomas-Gruber-90/RanorexLibrary GitHub Wiki
Run Application
Starts a desktop application.
Parameters:
- Required: Path to the executable file to start.
- Optional: List of command line arguments that should be passed to the application.
- Optional: The working directory for the application.
- Optional:
True
if the application should be started in maximized window mode,False
otherwise.
Examples:
Run Application calc.exe
Run Application yourApp.exe /help C:\\path\\to\\yourWorkingDirectory False
Close Application
Closes an application that contains the specified UI element.
Parameters:
- Required: RanoreXPath to an element in the application that should get closed.
- Optional: Grace period in ms. After this period, the application will be killed. When set to
0
, the application won't be killed.
Example:
Close Application /winapp[@packagename='Microsoft.WindowsCalculator'] 500
Start Browser
Starts the specified browser.
If you want to test specific browser versions, please use the Run Application
keyword instead and give the path the the .exe
file as parameter.
Parameters:
- Required: URL of the page that should be opened.
- Required: The browser that should be used. Can be any of these values:
Chrome
,Chromium
,Firefox
,Edge
, orIE
. If you want to use another browser, use theRun Application
keyword instead with the path to the executable file. Please note, however, that other browsers are not supported by Ranorex and you will most likely not get a dom to work with. - Optional: Command line arguments of the browser to start.
- Optional:
True
if an already-existing browser has to be closed,False
otherwise. - Optional:
True
if the browser window has to be opened in maximized mode,False
otherwise. - Optional:
True
if the browser cache has to be cleared before opening,False
otherwise. - Optional:
True
if the browser should be started in incognito mode,False
otherwise. - Optional:
True
if the cookies should be cleared before opening,False
otherwise.
Examples:
Start Browser www.ranorex.com Firefox
Start Browser www.ranorex.com Chrome ${EMPTY} False True false yes No
Close Browser
Closes a browser window.
Internally uses the Close Application
keyword. See there for the corresponding documentation, as both keywords are used in the same way.
Click
Performs a mouse click on a UI element.
Parameters:
- Required: RanoreXPath of the element that should get clicked.
- Optional: The location where the element should be clicked. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Which mouse button should be clicked. Possible values are listed on the corresponding .NET framework page.
- Optional: The duration of the mouse click in ms.
- Optional: Number of clicks that should be performed.
Examples:
Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button']
Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] UpperLeft
Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] UpperLeft ${EMPTY} 350
Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] ${EMPTY} ${EMPTY} ${EMPTY} 2
Right Click
Performs a Right click on an element. Equivalent to the Click
keyword with Right
as mouse button parameter.
Parameters:
- Required: RanoreXPath of the element that should get clicked.
- Optional: The location where the element should be clicked. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: The duration of the mouse click in ms.
- Optional: Number of clicks that should be performed.
Examples:
Right Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button']
Right Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] UpperLeft
Right Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] UpperLeft 350
Right Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] ${EMPTY} ${EMPTY} 2
Double Click
Performs a double click on an element. Equivalent to the Click
keyword with the last parameter set to 2
.
Parameters:
- Required: RanoreXPath of the element that should get clicked.
- Optional: The location where the element should be clicked. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Which mouse button should be clicked. Possible values are listed on the corresponding .NET framework page.
- Optional: The duration of the mouse click in ms.
Examples:
Double Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button']
Double Click /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] UpperRight Right 100
Mouse Down
Performs a mouse down action on an element. Is usually followed by a mouse move and a mouse up action, often to perform drag and drop operations.
Parameters:
- Required: RanoreXPath of the element that should get clicked.
- Optional: The location where the element should be clicked. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Which mouse button should be clicked. Possible values are listed on the corresponding .NET framework page.
- Optional: The duration of the mouse movement to the click location in ms.
Examples:
Mouse Down /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button']
Mouse Down /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] LowerRight Right 250
Mouse Move
Moves the mouse cursor to an element. Useful for drag and drop operations and to trigger hover-functionality.
Parameters:
- Required: RanoreXPath of the element that the mouse cursor is moved to.
- Optional: The location where the element should be clicked. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: The duration of the mouse move in ms.
Examples:
Mouse Move /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button']
Mouse Move /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num1Button'] UpperRight 150
Mouse Up
Performs a mouse up action. Usually preceded by a mouse down action.
Parameters:
- Optional: RanoreXPath of the element on which the mouse up action should be performed. Action is performed on current cursor location, if the RanoreXPath is omitted.
- Optional: Which mouse button should be clicked. Possible values are listed on the corresponding .NET framework page.
- Optional: The location where the element should be clicked. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: The duration of the mouse movement to the end location in ms.
Examples:
Mouse Up
Mouse Up [@packagename='Microsoft.WindowsCalculator']//button[@automationid='num2Button']
Mouse Up [@packagename='Microsoft.WindowsCalculator']//button[@automationid='num2Button'] Right UpperLeft 100
Drag and Drop
Performs a drag-and-drop action.
This keyword is an action consisting of a mouse down, a mouse movement, and a mouse up. It is usually used to perform drag-and-drop actions, but also other actions (like selecting many cells in a table etc.) can be performed using this keyword.
Parameters:
- Required: RanoreXPath of the source element.
- Required: RanoreXPath of the destination element.
- Optional: Where on the source element the mouse down action should happen. Possible values: Center, CenterLeft, CenterRight, LowerCenter, LowerRight, LowerLeft, UpperCenter, UpperLeft, UpperRight
- Optional: Where on the destination element the mouse up action should happen. Possible values: Center, CenterLeft, CenterRight, LowerCenter, LowerRight, LowerLeft, UpperCenter, UpperLeft, UpperRight
- Optional: How long it takes the mouse cursor to go to the surce element.
- Optional: How long it takes the mouse cursor to move to the destination element.
Examples:
Drag and Drop form[@title='Desktop']/element[@class='ShellTabWindowClass']//element[@instance='1']/container[@caption='ShellView']/?/?/list/listitem[@automationid='0'] /form[@title='Desktop']/element[@class='ShellTabWindowClass']//element[@instance='1']/container[@caption='ShellView']/?/?/list/listitem[@automationid='4']
Drag and Drop form[@title='Desktop']/element[@class='ShellTabWindowClass']//element[@instance='1']/container[@caption='ShellView']/?/?/list/listitem[@automationid='0'] /form[@title='Desktop']/element[@class='ShellTabWindowClass']//element[@instance='1']/container[@caption='ShellView']/?/?/list/listitem[@automationid='4'] CenterLeft UpperRight 300 1500
Key Sequence
Enters a key sequence into a specified UI element.
If you want to press keys without the necessity of a UI element, use the Key Shortcut
keyword instead.
Parameters:
- Required: RanoreXPath of the UI element that receives the key sequence.
- Required: Key sequence as specified above.
Each key is represented by a single character or an escape group. To specify a single keyboard character, use the character itself (e.g. use "aBc" to press the keys A, B+Shift, and C after another). Only the '{' character has a special meaning and needs to be escaped by preceding it with another '{' (specify "{{" to issue a '{' key press). Escape groups, signaled by braces "{}", may be used to produce a key action with any of the keys specified by the Keys enumeration. "{Z}" means that the 'z' key should be pressed, and "{return}" or "{enter}" that the Return key is to be pressed.
Additionally, in an escape group you can specify a modifier that determines whether the key should be hold down (e.g. {CONTROL down}), released (e.g. {shift up}), or pressed a number of times (e.g. {z 3}). In an escape group, key name and modifier must be separated by a single shift character.
The keys A to Z set the key modifiers (ALT, CTRL, SHIFT) and in particular the shift key depending on their case, even if used in an escape group. If these keys should not modify the shift key state, wrap them into an escape group and add "key" to the character, e.g. "{Rkey}" to press the R key without changing the shift key state.
Examples:
Key Sequence /form[@processname='iexplore' and @visible='True']/element[@accessiblename='Navigation Bar']//text[class='Edit'][1] www.ranorex.com
Key Sequence /form[@title='Untitled - Notepad']/text[@controlid='15'] II. Do not fear difficulty. Hard ground makes stronger roots.
Key Shortcut
Performs a key shortcut. The main difference to Key Sequence
is that Key Shortcut
doesn't need a RanoreXPath. This in turn means that you have to make sure yourself that your test execution knows how to wait for the correct system state before performing the key shortcut (e.g. you have to wait explicitly for the application to be opened before hitting the F1 key).
Parameters:
- Required: Key sequence that should get executed.
Each key is represented by a single character or an escape group. To specify a single keyboard character, use the character itself (e.g. use "aBc" to press the keys A, B+Shift, and C after another). Only the '{' character has a special meaning and needs to be escaped by preceding it with another '{' (specify "{{" to issue a '{' key press). Escape groups, signaled by braces "{}", may be used to produce a key action with any of the keys specified by the Keys enumeration. "{Z}" means that the 'z' key should be pressed, and "{return}" or "{enter}" that the Return key is to be pressed.
Additionally, in an escape group you can specify a modifier that determines whether the key should be hold down (e.g. {CONTROL down}), released (e.g. {shift up}), or pressed a number of times (e.g. {z 3}). In an escape group, key name and modifier must be separated by a single shift character.
The keys A to Z set the key modifiers (ALT, CTRL, SHIFT) and in particular the shift key depending on their case, even if used in an escape group. If these keys should not modify the shift key state, wrap them into an escape group and add "key" to the character, e.g. "{Rkey}" to press the R key without changing the shift key state.
Examples:
Key Shortcut {F12}
Key Shortcut {RMenu down}q{RMenu up}
Wait For
Waits for an element to exist.
Waiting for an element is a common use case, and in some cases it has to be done explicitly, for example if a web page should be opened before navigating it using a Key Shortcut
.
Parameters:
- Required: The RanoreXPath of the element that should be waited for.
- Optional: The timeout of this search in ms. If the element isn't found within this time span, then the test case fails.
Examples:
Wait For /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num5Button']
Wait For /winapp[@packagename='Microsoft.WindowsCalculator']//button[@automationid='num5Button'] 5000
Get Attribute Value
Returns an attribute value of a UI element as a string.
Parameters:
- Required: RanoreXPath of the element.
- Required: Name of the attribute that should be returned.
Example:
${retValue} Get Attribute Value /winapp[@packagename='Microsoft.WindowsCalculator']/?/?/text[@automationid='CalculatorResults']/container[@automationid='textContainer'] Caption
Set Attribute Value
Sets the value of an attribute of a UI element to a specific value.
Parameters:
- Required: RanoreXPath of the UI element.
- Required: Attribute that should be set.
- Required: New value of the attribute.
Example:
Set Attribute Value /form[@controlname='RxMainFrame']//text[@accessiblename='Enter your name'] AccessibleValue Dr. Strange
Validate Attribute Equal
Validates that an attribute is equal to the specified value.
Parameters:
- Required: The RanoreXPath of the element.
- Required: The attribute that should be validated.
- Required: The value of the attribute that should be validated against.
Example:
Validate Attribute Equal /form[@controlname='RxMainFrame']/?/?/tabpage[@controlname='RxTabIntroduction']/text[@controlname='lblWelcomeMessage'] ControlText Welcome, Dr. Strange!
Validate Attribute Not Equal
Validates that an attribute is not equal to the specified value.
Similar the Validate Attribute Equal
keyword, so look there for the documentation.
Add Device
Adds a device endpoint for testing iOS and Android applications.
Parameters:
- Required: Name of the endpoint. This value will be used in the
Run Mobile App
keyword to specify on which device the application has to be started. - Required: Has to be
Android
for Android devices andiOS
for iOS devices. - Required: Has to bei either
WLAN
orUSB
, depending on how the device is connected to the machine that runs Robot. - Required: Has to be the IP address (if connected via WLAN) or the USB serial (if connected via USB).
Example:
Add Device Galaxy S7 Test Device Android WLAN 192.168.14.3
Add Device iPad 10 Test Device iOS USB HT4AWJT01500
Run Mobile App
Starts an application on a mobile device.
Parameters:
- Required: Name of the endpoint. Endpoint first hast to be added using the
Add Device
keyword. - Required: Application to start.
- Optional:
True
if the application should be restarted,False
if it should just be brought to the foreground if it is already running.
Example:
Run Mobile App Nexus 9 com.dropbox.android False
Close Mobile App
Closes an application that contains a specific element.
Works in the same way as the Close Application
keyword, look there for documentation.
Touch
Performs a touch on a mobile element.
Very similar to the Click
keyword.
Parameters:
- Required: RanoreXPath of the mobile element that should get touched.
- Optional: The location where the element should be touched. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Duration of the touch action in ms.
Examples:
Touch /mobileapp[@title='com.dropbox.android']//button[@accessiblename='Enter']
Touch /mobileapp[@title='com.dropbox.android']//button[@accessiblename='Enter'] UpperRight 1000
Double Tap
Performs a double tap on a mobile element.
Very similar to the Double Click
keyword.
Parameters:
- Required: RanoreXPath of the mobile element that should get touched.
- Optional: The location where the element should be touched. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
.
Examples:
Double Tap /mobileapp[@title='com.dropbox.android']//button[@accessiblename='Enter']
Double Tap /mobileapp[@title='com.dropbox.android']//button[@accessiblename='Enter'] CenterRight
Long Touch
Performs a long touch on a mobile element.
Parameters:
- Required: RanoreXPath of the mobile element that should get touched.
- Optional: The location where the element should be touched. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Duration of the touch action in ms.
Examples:
Long Touch /mobileapp[@title='com.dropbox.android']//button[@accessiblename='Enter']
Long Touch /mobileapp[@title='com.dropbox.android']//button[@accessiblename='Enter'] Center 3000
Touch Start
Starts a touch on a mobile element.
Parameters:
- Required: RanoreXPath of the mobile element that should get touched.
- Optional: The location where the element should be touched. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
.
Examples:
Touch Start /mobileapp[@title='com.dropbox.android']//container/androidelement/container[@containertype='Frame']/androidelement/container[9]/text LowerLeft
Touch Move
Moves to a specific element.
Must be used after a Touch Start
keyword (or another Touch Move
) and can be used to make complex gestures, like swiping.
Parameters:
- Required: RanoreXPath of the mobile element where the movement should end.
- Optional: The location on the element where the movement should end. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Duration of the movement action in ms.
Example:
Touch Move /mobileapp[@title='com.dropbox.android']//container/androidelement/container[@containertype='Frame']/androidelement/container[9]/text Center 1500
Touch End
Lets a touch action end.
It is normally preceded by a Touch Start
or a Touch Move
keyword. It includes a move to the desired end location.
Parameters:
- Required: RanoreXPath of the mobile element where the movement should end.
- Optional: The location on the element where the movement should end. Possible values:
Center
,CenterLeft
,CenterRight
,LowerCenter
,LowerRight
,LowerLeft
,UpperCenter
,UpperLeft
,UpperRight
. - Optional: Duration of the movement action in ms.
Examples:
Touch End /mobileapp[@title='com.dropbox.android']//container[@containertype='Linear']/container[@containertype='Frame']/container[@containertype='Frame']/androidelement[1]/container[@containertype='Frame']/androidelement/container[@containertype='Frame']/container[3]/text
Touch End /mobileapp[@title='com.dropbox.android']//container[@containertype='Linear']/container[@containertype='Frame']/container[@containertype='Frame']/androidelement[1]/container[@containertype='Frame']/androidelement/container[@containertype='Frame']/container[3]/text CenterRight 50
Save Screenshot
Saves a screenshot to the given location.
Parameters:
- Required: RanoreXPath of the element that the screenshot is taken of.
- Required: Name of the image file. Should end with ".png"
- Required: Path to the directory where the screenshot should be saved.
Example:
Save Screenshot /form[@controlname='RxMainFrame']//picture[@controlname='RxStudioLogo'] logo.png C:\\Users\\user\\Documents
Report Screenshot
Places a screenshot into the Robot test log file.
The actual screenshot file is put into the working directory where the report and log files will also be generated by Robot.
Parameters:
- Required: RanoreXPath of the element that a screenshot is taken of.
Example:
Report Screenshot /form[@controlname='RxMainFrame']//picture[@controlname='RxStudioLogo']