This topic explains how to modify the user actions simulated by a web scenario. Sections include: To view and modify the action taken by a specific scenario step: You can use data sources to parameterize user actions. For instance, to have a "type" action iterate through a set of different values stored in an Excel spreadsheet. Parameterizing Tests with Data Sources, Variables, or Values from Other Tests. The element that is the source of a user action will be highlighted with a solid blue border in the scenario step’s Pre-Action Browser Contents tab. To quickly change the target of a user action, right-click the related element in the Pre-Action Browser Contents tab and choose the appropriate Modify command. If the user action that you want to change is not associated with a specific element (for instance, a "close" or "navigate" action), click the User Actions tab and choose a new action from the Action dropdown to modify the target. As you create and modify user actions for page elements, you may want to inspect the HTML to determine if you are adding actions to the appropriate elements. To see the HTML for an element, right-click the element and choose Inspect <Element>. You can configure most common user actions by selecting from the list of preset actions, then customizing them as needed to suit your needs. The available preset actions are described below. The User Actions tab contains configuration settings for many preset user actions. Choose a user action from the Action dropdown and configure the element locator settings. See Specifying Specialized Element Locators for more information. The element locator settings allow you to specify the element associated with the action. The following element locator options are available: Specifies the expected value for the attribute supplied by the Attribute Name field. Specifies the element that matches the previous criteria. Entering Many actions allow you to configure Window Name. This allows you to specify the name of the window you would like the action to occur in. Leaving this field blank indicates that the default window will be used. You can specify a variety of specialized element locators by setting Element Locator to Use XPath, then setting one of the available locator prefixes to the desired value. Available prefixes are: For example, to use the CSS locator If one of the following types of JavaScript popup dialogs opens in an action other than An error will not reported if a popup dialog opens during a wait action . This action clicks OK on any of the three types of JavaScript popup dialogs: alert, confirm, and prompt. For a multiselect combo box, this action adds one option to the selection. This can be the first selection or an additional selection. To select multiple items, use this action multiple times. This action enables/disables a specified check box element. This action clicks the specified element. Configuration notes: This action closes the specified window. For popup dialogs (alert, confirm, and prompt), this action either clicks Cancel (for confirm and prompt) or the X (for all three types of alert dialogs). This action double-clicks an element. This action drags one element to another location. Configuration notes: There are four ways to indicate how to move an element. For all of the following indicators, actions start at the element that will be dragged. All numbers are in pixels. The four options are: Start at offset and move by delta: offsetX,offsetY|deltaX,deltaY Drag the source element starting at offsetX, offsetY from the top-left corner of the source element and moving deltaX, deltaY. Negative deltas move the element up and to the left. This action executes the specified JavaScript within the context of the current web page. The specified JavaScript will execute in the same frame as the element defined by the element locator. If no element is defined, the JavaScript will execute in the top-most frame. To configure this user action: Configuration notes: The locator that is specified in the Element Locator section will be passed as the first parameter to the specified function. For example, assume you have 0 or 1 arguments are expected. When clicked, the dialog should say something like "0 or 1 arguments are expected in this script." When there is one argument, the argument is the element that was specified by the element locator in this user action. Example - Clicking hidden elements: Enter the following code into your Execute JavaScript action: Note that this code executes the click function on an element. In most cases, this will cause the click behavior to trigger. In some cases, this is insufficient and more code will be necessary to trigger the click. This action clicks the browser’s Back button. No arguments are needed. This action clicks the browser’s Forward button. No arguments are needed. This action hovers the pointer over the specified element. These actions fire keydown or keyup JavaScript events on an element. Configuration notes: This action maximizes the specified browser window. Configuration notes: This action navigates to the provided URL as though it was entered in the browser’s URL bar. Configuration notes: Enables you to add a custom action. This action has clicks Refresh. In a multiselect combo box, this action removes one option from the selection. This is the equivalent of SHIFT-clicking on a selected combo box selection. To remove multiple items, use this action multiple times. This action right-clicks on the specified element. This action scrolls the web application by the number of pixels specified for the x and y axis. Negative values indicate "scroll left" (for the x-axis) or "scroll up" (for the y-axis). This action scrolls the web application to the specified pixel position (x and y axes). In a single-select combo box, this action selects a single option in the combo box. If an option is already selected, this action will change the selection. Configuration notes: This action submits a form, or an element within a form, to the remote server. Configuration notes: This action enters the specified text into the specified element. This action enters text into a prompt dialog. Configuration notes: This action enters specified text into the specified element. The text will be masked in the field as well as encrypted upon storage. This action unchecks/clears a checked check box. This action simulates the browser waiting the specified number of milliseconds before continuing to the next step. You can use the following special character mappings to specify special characters within Number pad keys Function keys These character mappings can be used with a scripted "Text Input" value such as the following script, which will type the word "test" and then send the tab key: This does NOT act as a key modifier. For example, you CANNOT perform a CTRL-click by sending the control character and then performing a click. Sending the character simulates a user pressing and releasing the corresponding button. User Actions Configuration Overview
Using Data Sources to Parameterize User Actions
Identifying Elements Associated with User Actions
Changing the Target of a User Action
Inspecting the HTML for Elements
Understanding Preset Actions
User Actions Tab
Element Locator Settings
Element Specifies the element name (for example, "img", "div", or "a") that the action should apply to. To allow any element, enter Any
into this field.Attribute Name Specifies the attribute name to identify the element (for example, "title", "id", or "name"). You can configure this value using one of the following mechanisms. Attribute Value Index 0
means that the first element that matches the "Element," "Attribute Name," and "Attribute Value" criteria will be used. Entering 1
means that the second element that matches will be used, and so on.Specifying Specialized Element Locators (CSS, ALT attribute, etc.)
tag.classA
, use the XPath locator css=tag.classA
Errors for Popup Dialogs
Accept Script Dialog
, Dismiss Script Dialog
, or Type into Script Dialog
, then an error will be reported unless this is the last test in your scenario:Accept Script Dialog
Addselection
Check
Click
Close
Dismiss Script Dialog
Doubleclick
Dragdrop
Execute JavaScript
function userFunction(locator) {
locator.click();
}
The element specified in the element locator would be passed to the function as the locator parameter in this script so that you can act on it as you wish.function click(element) {
element.click();
}
Go Back
Go Foward
Hover
Keydown / Keyup
Maximize Window
Navigate
Other
Refresh
Removeselection
Right-click
Scroll By
Scroll To
Select
Submit
Type
Type into Script Dialog
Type Password
Uncheck
Wait
Special Character Mappings for Type Actions
type
actions:NULL \uE000
CANCEL \uE001
HELP \uE002
BACK_SPACE \uE003
TAB \uE004
CLEAR \uE005
RETURN \uE006
ENTER \uE007
SHIFT \uE008
CONTROL \uE009
ALT \uE00A
PAUSE \uE00B
ESCAPE \uE00C
SPACE \uE00D
PAGE_UP \uE00E
PAGE_DOWN \uE00F
END \uE010
HOME \uE011
LEFT \uE012
UP \uE013
RIGHT \uE014
DOWN \uE015
INSERT \uE016
DELETE \uE017
SEMICOLON \uE018
EQUALS \uE019
NUMPAD0 \uE01A
NUMPAD1 \uE01B
NUMPAD2 \uE01C
NUMPAD3 \uE01D
NUMPAD4 \uE01E
NUMPAD5 \uE01F
NUMPAD6 \uE020
NUMPAD7 \uE021
NUMPAD8 \uE022
NUMPAD9 \uE023
MULTIPLY \uE024
ADD \uE025
SEPARATOR \uE026
SUBTRACT \uE027
DECIMAL \uE028
DIVIDE \uE029
F1 \uE031
F2 \uE032
F3 \uE033
F4 \uE034
F5 \uE035
F6 \uE036
F7 \uE037
F8 \uE038
F9 \uE039
F10 \uE03A
F11 \uE03B
F12 \uE03C
META \uE03D
ZENKAKU_HANKAKU \uE040
def typeTestThenTab() {
return "test\uE004";
}
Overview
Content Tools