Help Docs

Advanced mobile script editing for the Synthetic Mobile Application monitor

You can use the advanced mobile script editor to customize the transaction flow of your Synthetic Mobile Application monitor. You can simulate complex user interactions using advanced commands by either dragging and dropping them from the Create Mobile Script section or manually entering them in the Create Mobile Script editor. This lets you monitor your mobile application’s performance more effectively.

Following are the various commands that are used to update the web script. Please note how these expressions are formatted in the editor.

Note
  • Every parameter in a command is mandatory. However, for the parameter DISPLAY_NAME, you can pass an empty value between double quotes while maintaining the defined format for each command.
  • If you are attempting to perform a click that would initiate a download, you will see a pop-up "File download is not supported". Please note that the Synthetic Mobile Application monitor does not support a file download action and you will need to close the pop-up box to proceed.
  • Click_element_by_id/name/linktext/css/xpath("<ELEMENT_ID/NAME/LINKTEXT/CSS/XPATH>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

    When a command has multiple names separated by "/," it indicates that the function is associated with the commands which have various types of primary identifiers.

    There are five types of primary identifiers for the click on an element:
    click_element_by_id("<ELEMENT_ID>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")
    click_element_by_name("<NAME>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")
    click_element_by_linktext("<LINKTEXT>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")
    click_element_by_css("<CSS>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")
    click_element_by_xpath("<XPATH>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Mobile script commands

Begin Step Click Element Wait Assert Text Swipe Right
Swipe Left Swipe Down Tap Double Tap Drag and drop
Swipe between elements Press and hold Long press Tap at coordinates Press Back
Switch Potrait Switch Landscape  

Command reference and descriptions

Explore the list of available commands used in mobile script creation along with detailed explanations to help you build accurate and effective transaction flows.

1. Create a step

This command allows you to mark the beginning of a step.

Command syntax:
begin_step("<STEP_NAME>", "<STEP_ACTIVITY_NAME>") begin_step("<STEP_NAME>", "<STEP_ACTIVITY_NAME>", "<STEP_STATUS>")

Example: begin_step("Step 5: Click Element", "Click id") begin_step("Step 6: Click Element", "Click id", "true") begin_step("Step 7: Click Element", "Click text,"false")
Note
  • The attribute is not a mandatory parameter.
  • If the attribute STEP_STATUS> is set to true, the transaction proceeds to the next step even if the current step fails.
  • If it is set to false, the transaction will stop if the current step fails.

2. Click an element

This command allows you to simulate a click action on an element using various selector types.

Command syntax:
click_element_by_id/name/linktext/css/xpath/accessibilityid/androiduiautomator("<ELEMENT_IDENTIFIER>", "<DISPLAY_NAME>", "<INTELLIGENT_PLAY_CANDIDATES>")

Example:
click_element_by_id("corporate","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP#css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#//a[contains(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")
Note
  • Use the appropriate identifier type in the command:
    • click_element_by_id: The first parameter must be the element’s ID.
    • click_element_by_name: The first parameter must be the name.
    • And so on for linktext, css, xpath, accessibilityid, and android ui automator.
  • INTELLIGENT_PLAY_CANDIDATES:
    This is a list of alternative identifiers used to locate the element if the primary one fails.
    • Use #SEP# to separate different types of identifiers (ID, Name, CSS, etc.).
    • Use #XPATH# to separate multiple XPath expressions.

3. Pause for a specific time

This command allows you to pause the execution of the script for a defined period.

Command syntax: 
wait("<TIME_IN_MILLISECONDS>")
Example:
wait("5000")
Note

The time must be specified in milliseconds.

4. Verify the presence of text on a webpage

This command checks whether the specified text is present on the current webpage.

Command syntax:
assert_text_present("\"<TEXT_1>\" \"<TEXT_2>\"", "<IGNORE_FAILURE>")
Example:
assert_text_present("CORPORATE", "true")assert_text_present("\"CORPORATE\" \"PRODUCTS\"", "true")
Note
  • To verify multiple texts, enclose each instance of text in double quotes and escape the quotes if needed (e.g., \"CORPORATE\").
  • The second parameter controls failure behavior:
    • "true": The script will continue execution even if the text is not found.
    • "false": The script will stop execution as soon as the failure is detected.

5. Verify the absence of text on a webpage

This command checks whether the specified text is not present on the current webpage.

Command syntax:
assert_text_not_present("\"<TEXT_1>\" \"<TEXT_2>\"", "<IGNORE_FAILURE>")
Example:
assert_text_not_present("error", "true")
assert_text_not_present("\"error\" \"warning\"", "true")
Note
  • To verify the absence of multiple texts, enclose each text in double quotes and escape them when needed (e.g., \"error\").
  • The second parameter determines playback behavior:
    • "true": The script continues even if the text is present (i.e., failure ignored).
    • "false": The script stops as soon as the text is found (i.e., failure encountered).

6. Swiping on a screen

This command allows you to swipe the screen in various directions before performing further actions in your mobile transaction.

Command syntax:
swipe_up("<NUMERICAL_VALUE>") swipe_down("<NUMERICAL_VALUE>") swipe_right("<NUMERICAL_VALUE>") Swipe_left("<NUMERICAL_VALUE>")

Example:
swipe_up("20")
swipe_down("30")
swipe_right("50")
swipe_left("70")
Note
  • represents a percentage value that defines the extent of the scroll.
  • You can include values from zero to 100.

7. Tap an element

This command allows you to simulate a precise tap action on a mobile screen by calculating the element’s center and performing a low-level touch action.

Command syntax:
tap_by_id/name/linktext/css/xpath/accessibilityid/androiduiautomator("<ELEMENT_IDENTIFIER>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")
Example
tap_by_id("corporate","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP#css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#//a[contains(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")

8. Double tap an element

This command simulates a double-tap action on a mobile screen by calculating the element’s center point and performing a low-level touch action.

Command syntax:
double_tap_by_id/name/linktext/css/xpath/accessibilityid/androiduiautomator("<ELEMENT_IDENTIFIER>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
tap_by_id("corporate","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP#css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#//a[contains(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")

9. Drag and drop element

This command enables you to drag an element and drop it onto a target element.

Command syntax:
drag_and_drop("<ELEMENT_ONE_IDENTIFIER>","<ELEMENT_TWO_IDENTIFIER>","<ELEMENT_ONE_IDENTIFIER_VALUE>","<ELEMENT_TWO_IDENTIFIER_VALUE>")

Example:
drag_and_drop("id","accessibilityid","corporate","finance")

10. Swipe between elements

This command allows you to simulate a swipe action between two elements.

Command syntax:
swipe_between_elements("<FROM_ELEMENT_IDENTIFIER>","<FROM_ELEMENT_IDENTIFIER_VALUE>","<TO_ELEMENT_IDENTIFIER>","<TO_ELEMENT_IDENTIFIER_VALUE>"))Example:

Example:

swipe_between_elements("id","accessibilityid","corporate","finance")

11. Press and hold element

This command allows you to simulate a press-and-hold action on an element for a specified duration.

Command syntax:
press_and_hold_by_id/name/linktext/css/xpath/accessibilityid/androiduiautomator("<ELEMENT_IDENTIFIER>","<DURATION_IN_MILLISECONDS>","<DISPLAY_NAME>","<INTELLIGENT_PLAY_CANDIDATES>")

Example:
press_and_hold_by_id/name/linktext/css/xpath/accessibilityid/androiduiautomator("corporate","2500","disp_corp","#SEP#id=corporate#SEP#name=corporate#SEP#linktext=CORPORATE#SEP#css=#topmenu>li>a#SEP#xpath=//a[contains(text(),'CORPORATE')]#XPATH#//ul[@id='topmenus']/li/a#XPATH#//a[contains(@href, 'corporate.html')]#XPATH#//tr[2]/td/ul/li/a#XPATH##SEP#")
Note

The maximum duration is capped at 5,000 milliseconds.

12. Long press element

This command allows you to simulate a long-press action on an element, holding it for 750 milliseconds.

Command syntax:
long_press("<ELEMENT_IDENTIFIER>","<ELEMENT_IDENTIFIER_VALUE>"))
Example:
long_press("id","corporate")

13. Tap at coordinates

This command allows you to simulate a tap action at a specific (x, y) position on the screen. It is useful for interacting with areas in the UI that lack identifiable element selectors, such as canvas elements, custom maps, or system-level overlays.

Command syntax:
tap_at_coordinates("<xcoordinate>","<ycoordinate>")

Example:
tap_at_coordinates("306","1999")
Note
  • x and y represent pixel positions on the screen.
  • Valid values must be within the screen’s width and height. Example: On a 3840×2160 screen, valid ranges are x: 0–3839, y: 0–2159.
  • The default tap behavior simulates a finger touch using low-level pointer input.

14. Go to the previous screen

This command allows mobile apps to go back to the previous screen, just like when you press the back button on your browser or phone.

Command syntax:
press_back()

15. Hide keyboard

This command allows you to hide the on-screen keyboard after entering text in a field or whenever the keyboard is open on the screen.

Command syntax:
hide_keyboard()

16. Switch screen orientation

This command allows you to switch the mobile screen orientation between portrait and landscape modes.

Command syntax:
switch_to_portrait()
switch_to_landscape()

Related articles

Was this document helpful?

Would you like to help us improve our documents? Tell us what you think we could do better.


We're sorry to hear that you're not satisfied with the document. We'd love to learn what we could do to improve the experience.


Thanks for taking the time to share your feedback. We'll use your feedback to improve our online help resources.

Shortlink has been copied!