SeeTest Automation Commands: A Detailed Explanation with Examples

By Vijay

By Vijay

I'm Vijay, and I've been working on this blog for the past 20+ years! I’ve been in the IT industry for more than 20 years now. I completed my graduation in B.E. Computer Science from a reputed Pune university and then started my career in…

Learn about our editorial policies.
Updated March 7, 2024

Introduction to SeeTest Automation Commands:

In our previous tutorial, we learned about some basic commands that can perform simple actions like click, send a text to a text box, wait for an element etc.

This tutorial is part of SeeTest Mobile Test Automation series.

When we are about to work with mobile apps that require complex actions to be performed, we need to explore more advanced SeeTest commands. Here, we will discuss all the SeeTest commands including advanced ones to perform complex actions on the app, commands to perform actions on the OS and at the hardware level.

SeeTest Automation Commands

This tutorial gives you a complete overview of the various types of SeeTest Automation Commands along with real-life examples and a brief explanation of each command for your easy understanding.

SeeTest Automation Commands

SeeTest Automation provides commands for almost all of the actions that can be performed on a mobile device.

If one action is missing, the same can be achieved by using some workarounds. We will discuss some useful commands that might help while testing mobile apps.

Object Related Commands

This section describes SeeTest Automation commands that are related to actions performed on Objects in the mobile apps.

#1) Basic Commands

Given below is a list of all the basic commands along with their usage.

CommandUse
ClickClick on an object
IsElementFoundCheck for the presence of an element
VerifyElementFoundVerify presence of an element
ElementGetPropertyGet value of an element’s property
ElementSendTextSend text to textbox without clicking on it
GetElementCountGet count of the element matching a given xpath
VerifyElementNotFoundVerify the invisibility of an element
WaitForElementWait for the presence of an element for a specified time period
WaitForElementToVanishWait for the invisibility of an element for a specified time period

#2) Advanced Commands

Given below is a list of all the advanced commands along with their usage.

CommandUse
Click (Offset)Click on an object at a specified offset
ClickCoordinateClick on the specified coordiantes
ClickInClick inside an element
DragPerform Drag operation
ElementListSelectSelect an element from a list
ElementSetPropertySet value of a property of an element
ElementSwipePerform swipe on an element
WaitForElementToVanishWait for the invisibility of an element for a specified time period
VerifyInVerify for the presence of an element inside another element
GetCoordinateColorGet RGB color value at a coordinate
DragDropPerform drag and drop operation
LongClickPerform touch and hold

Both these Basic and Advanced commands are explained one by one in detail below.

#1) Click

ParameterDescriptionTypePossible values
ZoneType of the elementStringNATIVE/WEB/TEXT/default
ElementElement representationStringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the elementint0
Click countNumber of clicksint0

Default zone is selected for identifying the objects in the ‘default’ object repository. If Text is specified as Zone, then SeeTest Automation searches for the text specified for Element (2nd argument) in the UI and clicks on it.

Throws an exception if the element is not found.

Example: client.click(“NATIVE”, “text=Close”, 0, 1);

#2) IsElementFound

ParameterDescriptionTypePossible values
ZoneType of the elementStringNATIVE/WEB/TEXT/default
ElementElement representationStringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the elementint0

Default zone is selected for identifying the objects in the ‘default’ object repository. If Text is specified as Zone, then SeeTest Automation searches for the text specified for Element (2nd argument) in the UI.

This command does not throw an exception if the desired element is not found, instead, it returns false.

Example: boolean found = client.isElementFound(“NATIVE”, “id=loginButton”, 0);

#3) VerifyElementFound

ParameterDescriptionTypePossible values
Zone Type of the elementString NATIVE/WEB/TEXT/default
Element Element representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0

This is similar to IsElementFound, but throws an exception if the desired element is not found.

#4) ElementGetProperty

ParameterDescription TypePossible values
Zone Type of the element StringNATIVE/WEB/TEXT/default
Element Element representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
PropertyProperty of the element whose value is to be retrievedString“id”

This command throws an exception if the desired element is not found.

Example: String text = client.elementGetProperty(“NATIVE”, “text=Login”, 0, “text”);

#5) ElementSendText

ParameterDescriptionTypePossible values
Zone Type of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
TextProperty of the element whose value is to be retrieved String“admin”

This command throws an exception if the desired element is not found.

Example: client.elementSendText(“NATIVE”, “hint=Password”, 0, “admin”);

#6) GetElementCount

ParameterDescriptionTypePossible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
Element Element representation StringString

This command throws an exception if the desired element is not found.

Example: client.getElementCount(“NATIVE”, “text=Login”);

#7) VerifyElementNotFound

ParameterDescription TypePossible values
Zone Type of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0

This command throws an exception if the desired element is found.

Example: client.verifyElementNotFound(“NATIVE”, “text=Login1”, 0);

#8) WaitForElement

ParameterDescription TypePossible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
Timeout Wait timeout in milliseconds long10000

This command returns false if the element is not found within the specified time limit. No exception is thrown.

Example: boolean found = client.waitForElement(“NATIVE”, “text=Login”, 0, 10000);

#9) WaitForElementToVanish

ParameterDescriptionTypePossible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
TimeoutWait timeout in milliseconds long10000

This command returns false if the element does not vanish within the specified time limit.

Example: boolean vanished = client.waitForElementToVanish(“NATIVE”, “text=Login1”, 0, 10000);

#10) Click (Offset)

ParameterDescriptionTypePossible values
XX coordinate of the click locationint300
YY coordinate of the click locationint500
Click countNumber of clicksint1

Example: client.click(“NATIVE”, “text=Login”, 0, 1, 300, 500);

#11) ClickCoordinate

ParameterDescriptionTypePossible values
XX coordinate of the click locationint300
YY coordinate of the click locationint500
Click countNumber of clicksint1

Example: client.clickCoordinate(300, 500, 1);

#12) ClickIn

ParameterDescriptionTypePossible values
ZoneElement type StringNATIVE/WEB/TEXT/default
Search Element Element representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndexint1
DirectionSearch direction StringLeft/Right/Up/Down/Inside
ClickElementZone Type of the element to be clicked String“TEXT”
ClickElement Representation of the element to be clicked String “Login”
ClickElementIndex Index of the element to be clickedint0
Width Width of the search int0
HeightHeight of the search int0
Click count Number of clicks int1

This command is useful if we need to click on an element inside another element. Width and Height as 0 indicates searching from the start to the end.

The below example is to click on the text ‘Login’ inside the Login button.

Example: client.clickIn(“NATIVE”, “text=Login”, 0, “inside”, “TEXT”, “Login”, 0, 0, 0, 1);

#13) Drag

ParameterDescriptionTypePossible values
ZoneElement type String NATIVE/WEB/TEXT/default
Search Element Element representation String Id=loginButton or //*[@id=’loginButton’]
Index indexint 1
XOffset X Offset int 0
YOffset Y Offset int 100

If XOffset is set to 0, then this command will drag vertically and if YOffset is set to 0 then it drags horizontally.

Example: client.drag(“NATIVE”, “text=Login”, 0, 0, 100);

#14) ElementListSelect

ParameterDescription Type Possible values
List Locator Element type String Id=countryList
Element Locator Element representation Stringtext=USA or //*[@text=’USA’]
IndexNumber of clicks int1
ClickWhether to click or not booleantrue

Example: client.elementListSelect(“id=countryList”, “text=USA”, 0, true);

#15) ElementSetProperty

ParameterDescriptionTypePossible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
Index Index of the element int 0
PropertyProperty name String“id”
ValueValue to be set for the property String“loginButton”

Not all the apps allow changing the properties set by the developer.

Example: client.elementSetProperty(“NATIVE”, “text=Login”, 0, “id”, “loginButton”);

#16) ElementSwipe

ParameterDescription Type Possible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
DirectionDirection to swipe StringUp/Down/Left/Right
OffsetSwipe offset int300
TimeSwipe overall time int300

If the time is minimized, the swipe intensity will be more and the swipe will be done quickly.

Example: client.elementSwipe(“NATIVE”, “text=Login”, 0, “Right”, 300, 300);

#17) WaitForElementToVanish

ParameterDescriptionTypePossible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
ElementElement representation String Id=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
TimeoutVanish timeout long10000

Example: client.waitForElementToVanish(“NATIVE”, “text=Close”, 0, 10000);

#18) GetCoordinateColor

ParameterDescription TypePossible values
XX coordinateint400
YY coordinateint500

This command returns coordinate color as RGB value. We need to extract Red, Green and Blue color information from it to find the actual color.

Example: int rgbColor = client.getCoordinateColor(300, 300);

#19) LongClick

ParameterDescription TypePossible values
ZoneType of the element StringNATIVE/WEB/TEXT/default
ElementElement representation StringId=loginButton or //*[@id=’loginButton’]
IndexIndex of the element int0
Click count Number of clicks int1
XX offset from element int100
YY offset from elementint100

Example: client.longClick(“NATIVE”, “text=Login”, 0, 1, 100, 100);

There are still many more commands to perform complex actions. You can check SeeTest Automation’s command window to explore more such commands.

Device Related Commands

This section describes SeeTest Automation commands that are related to the actions performed on the mobile device itself.

#1) SendText

This is to perform the actions such as navigating back, pressing the home button, changing orientation etc. This can also send texts to the text box if the text box is selected.

Example: client.sendText(“{ESC}”);

The code given in the above example simulates the action of Android’s back button functionality. SeeTest supports a number of such phrases enclosed in { and } that can be included in the SendText command to perform special actions.

Those are listed in the below table.

TextUse
{HOME} Simulates pressing Home button
{BKSP} Press back space
{PORTRAIT} Change orientation to Portrait mode
{LANDSCAPE} Change orientation to Landscape mode
{ENTER} Simulate operation of Enter button
{WAKE} Wake screen
{UNLOCK} Unlock device
{CLOSEKEYBOARD} Close opened keyboard

#2) Swipe

This is to perform the swipe operation on the device level instead of swiping on an object.

The command is similar to ElementSwipe except it is missing Zone and Element.

#3) Flick

The flick is a fast swipe performed on the device. This is useful when we need to scroll up/down more.

Using swipe, in this case, will consume more time.

Example: client.flick(“DOWN”, 400);

#4) CloseKeyboard

This is to close the device keyboard.

Example: client.closeKeyboard();

#5) Reboot

This command is used to reboot the device.

A wait timeout is passed as the argument indicating the timeout wait for rebooting the device. If 0 is passed, the device will perform an instant reboot.

Example: client.reboot(1000);

#6) GetVisualDump

This is used for getting the Xml (of Native elements) and HTML (of Web Elements) representation into a String.

If this is used in a web page, it will return the HTML source of that webpage.

#7) Pinch

This is used to perform the pinch operation.

#8) Shake

This command simulates the shake operation.

#9) Run

This command is used in the Android devices to run adb commands.

We can make use of this command to run adb commands for functionalities outside the scope of SeeTest Automation such as getting package name of an application, to check whether an application is installed on the device or not, etc.

It can also be used to activate and deactivate the Airplane mode via adb command.

#10) 2Cx

This command is used to retrieve the horizontal pixel value corresponding to a percentage passed with the command.

A percentage 100 will return the maximum width of the device in pixels.

#11) P2Cy

This command is similar to the above command except that it calculates a vertical pixel value for a percentage passed with the command.

A percentage 100 will return the maximum height of the device in pixels.

Application Related Commands

This section describes the SeeTest Automation commands that are related to the actions performed on the mobile applications.

#1) Install

This command is used to install applications on the device.

Arguments of this command are as follows:

  • App path: Application name if the application is available in the SeeTest package manager, otherwise path of the application. For Android apps, Activity Name is the application name.
  • Instrumented: Boolean value indicates whether to install the application as instrumented or not. Setting true will install the application as instrumented.
  • Keep data: Boolean value indicates whether to keep the application data or not. Setting true will keep the app data.

#2) Uninstall

This command performs uninstallation of an application. It takes only one argument that is the app path.

If the application that needs to be removed is available in the SeeTest package manager, then just the app name is enough. Otherwise, the app path is required.

#3) Launch

This is used to launch an application on the device.

Its arguments are:

  • Activity: App name or activity name.
  • Instrumented: Boolean value indicates whether to launch the app in the instrumented mode or not. Only apps that are installed as instrumented can be launched in the instrumented mode. Setting true will launch the app in instrumented mode.
  • Stop if running: Boolean value indicates whether to close the app if it is already running. Setting true will close the app and re-launch it.

#4) ApplicationClearData

This is applicable for Android devices to clear the app data.

#5) SimulateCapture

This command simulates the operation of the device camera by taking pictures by using the device camera and stores in a file whose path is specified in the argument.

Utility Commands

Given below is a lost of various Utility commands along with a brief explanation.

#1) SetDevice

This command is used to set the test device. The device name is displayed in the SeeTest Automation and after connecting, it needs to be passed as the parameter.

#2) WaitForDevice

This command waits for a device with a specified query for a period.

The query should be any of the following:

  • Device added: If a device is available on the SeeTest device list.
  • Manufacture
  • Model
  • Name
  • OS: Operating system
  • Remote: If a device is connected through SeeTestCloud or not (values are true/false).
  • Serial number: S/N of the device.
  • Version: OS version (KitKat, Lollypop etc.)
  • Version number: OS version number (4.4.0 – 4.4.4 for KitKat)

Examples:

client.waitForDevice(“@os=ios”, 3000); – Wait for iOS device 3 seconds
client.waitForDevice(“@versionNumber=5.1.1”, 3000); – Wait for Android device with OS version as 5.1.1

This command is very useful during parallel execution in which we do not have to explicitly set the device name by SetDevice command. SeeTest will choose appropriate devices dynamically to the appropriate ports.

#3) GetDevicesInformation

Get necessary information of connected devices.

#4) GetConnectedDevices

Get connected device names.

#5) GetInstalledApplications

Get a list of applications installed on the device.

#6) AddDevice

Add a device to its serial number and the device name.

Conclusion

In this tutorial, we learned about the various types of commands provided by SeeTest Automation to perform a series of actions on the mobile device or app.

By using the above commands, we can perform automation of some real-time applications on our own mobile device. But in some cases, when an application does not have enough properties to be recognized during Object Spy, we need to seek alternatives to get it recognized.

The alternatives provided by SeeTest Automation is image and text identification. Same as this situation, we may also face other challenges like inconsistent device notifications during automation test execution, parallel execution, automation of web components etc.

In our next 4th and last tutorial, we will address these situations and possible ways or workarounds to overcome these challenges in detail using a real-time mobile app.

Was this helpful?

Thanks for your feedback!

Leave a Comment