Official Content

The UITestSD external object allows for the development of User Interface (U.I.) automated tests such as, for example, of Panel objects.

image_2019123151343_1_png

This external object is loaded in your Knowledge Base when you create the first UI Test object.

Properties

None

Methods

Parameters received by most methods

Several of the methods described below (and used in UI Test objects) receive parameters to indicate a text on a screen, a control name, or other details. Below are general aspects of the parameters received by most of the methods.

controlName

It's the name of a control (as shown in the Control Name property) in the GeneXus object where it is defined.
Examples: "&numeric" (for a variable), "CustomerName" (for an attribute), "Save" (for a button).
Note: The casing is not important because GeneXus ignores it.

context

It allows indicating the container in which the control is located.
In some cases, it is necessary to disambiguate the name of the control. For example, if there is a Component on the screen, there may be two controls with the same control name.

For example, if you want to tap on a button called "Button1" located in the second row of the "Grid1" grid, you must write:

&app.Tap("Button1", "Grid1.item(2)")   //&app is a variable based on the UITestSD external object

Notes:
- The context defines a route where controls should be found, though it is not necessary for the route to be complete. For example, in the above case, the "button1" button could also be inside a "Grid1Table" table, which will not have to be indicated.
- For controls representing collections (Grid, Horizontal Grid, Tab Control, etc.), the "item" allows indicating an element within the collection.
Predefined contexts: In many cases, the context depends on the names of the controls –for example, "Grid1"– but there are also cases in which the context may be predefined. This happens with the controls in the Application Bar. To this end, an Enumerated Domain called UITestingContext is defined.

UITestingContext Enumerated Domain features

- It is based on the same data type as the context in the method parameters, i.e. VarChar(40).
- It has only one value: ApplicationBar (value: "applicationbar") that represents the context of the Application Bar. When this context is indicated, only elements found there will be searched.

- If the ApplicationBar context is indicated, in addition to searching for the elements that are visible there, the elements that were placed in the Application Bar at design time should also be searched. Because there is not enough space, they were grouped by the flexible client and it is necessary to press an additional button to find them.  


target

"Target" or "Action Target" refers to an action that may be done on:

  • A controlName, or
  • Any Text shown on the screen.

Notes:
- When searching for elements on the screen, the search is done first by controlName and if none is found, then the search is done by text.
- If there is more than one control fulfilling the conditions, then you use the first one found (non-deterministic).


expected

This boolean parameter indicates if you expect a text on the screen:

  • If you indicate True, you are expecting the text on the screen. If it isn't on the screen the test fails. 
  • On the other hand, if you indicate False, the test will fail if the text is on the screen.

 

Methods for Actions

Back

Simulates the action of the back button in the device in the case of Android, and it is a tap on the button for that purpose in the case of iOS.

Back()

Tap

It performs a tap on a given point on the screen (<target>). 

Tap(<target> [, <context>])                    

View Parameters received by most of the methods


LongTap

It performs a long tap on a given point on the screen (<target>). 

LongTap(<target> [, <context>])

View Parameters received by most of the methods


DoubleTap

It performs a double tap on a given point on the screen (<target>).

DoubleTap(<target> [, <context>])

View Parameters received by most of the methods


TapSystemAlertIfShown

When you run an application on a device, you might see non-application dialogs during execution; they are system dialogs. These dialogs are displayed by the system, for example, so that the user can grant or deny certain permissions. With this method, you can control those actions in the UI Test object.

TapSystemAlertIfShown(<button> [, <alertType>])

where

  • <button> - Indicates the button on which to tap in case the dialog is displayed. It is based on the SystemAlertButton Enumerated Domain that defines which button the TapSystemAlertIfShown function should tap on.
  • <alertType> - Indicates the type of alert to interact with. This parameter is optional. If you are not prompted for the type of alert, then any system dialog that is presented is considered.    

Possible values offered by the SystemAlertButton Enumerated Domain:

  • DoNotAllow
  • Ok
  • AllowOnce
  • AllowWhenInUse
  • AllowAlways

SystemAlertType is the enumerated domain that indicates the different types of dialog that the TapSystemAlertIfShown method can handle. The possible values are as follows:

  • Bluetooth
  • Calendar
  • Camera
  • Contacts
  • Location
  • Microphone
  • Photos
  • Storage
  • Any

Sample

//&app is a variable based on the UITestSD external object

&app.Tap("GetLocation")           
&app.TapSystemAlertIfShown(SystemAlertButton.AllowOnce,SystemAlertType.Location)
&app.Wait(3000)
&app.verifyMsg("Done")
&app.Tap("OK")

Fill

It enters a value in a given control of the Edit type.

fill(<controlName>, <value> [, <context>])

View Parameters received by most of the methods


PickDate

It enters a value in a field of the Date type using the corresponding picker.

pickDate(<controlName>, <year>, <month>, <day>, [, <context>])

View Parameters received by most of the methods


PickDateTime

It enters a value in a field of the DateTime type using the corresponding picker.

pickDateTime(<controlName>, <year>, <month>, <day>, <hour>, <minutes>, [, <context>])

View Parameters received by most of the methods


PickTime

It enters a value in a field of the Time type (a.k.a. DateTime without the Date part) using the corresponding picker.

pickTime(<controlName>, <hour>, <minutes>, [, <context>])

View Parameters received by most of the methods


SelectValue

It enables the selection of a value from a list of values of a Combo Box or Radio Button, given by its Control Name. The value to be selected is indicated in the "value" parameter.

selectValue(<controlName>, <value> [, <context>])

View Parameters received by most of the methods


Swipe

It performs a swipe over the screen in the direction indicated by the parameter. The starting point of the swipe depends on the parameter. There is also the option to indicate the control where it should start. In the absence of an indication, the swipe will start at a fixed point on the screen (the fixed point will depend on the direction).

Swipe(<direction> [, <controlName>] [, <context>])

where <direction> may be "Up", "Down", "Left", or "Right".

  • Up - does a swipe upwards from the center of the lower margin on the device (some pixels above the border) or from the control if it is indicated.
  • Down - does a swipe downwards from the center of the upper margin on the device (some pixels under the border) or from the control if it is indicated.
  • Left - does a swipe to the left from the center of the right margin on the device (some pixels to the left of the border) or from the control if it is indicated.
  • Right - does a swipe to the right from the center of the left margin on the device (some pixels to the right of the border) or from the control if it is indicated.

View Parameters received by most of the methods

Note: In iOS, it is not possible to indicate from which position the swipe should start. It is always done (apparently) from the center of the control.


Wait

Waits for a given number of milliseconds.

wait(<milliseconds>)

 

Methods for Verifications

Verifications will cause the test case to fail in case of non-compliance. When conditions are fulfilled, they do not cause the test to fail.

VerifyText

Verifies whether a text is on screen, anywhere, unless a context has been indicated.

verifyText(<string> [, <expected>] [, <context>])

View Parameters received by most of the methods


VerifyGridRowsCount

Verifies whether the number of rows on a grid equals the given value.

verifyGridRowsCount(<grid control name>, <value> [, <expected>] [, <context>])

View Parameters received by most of the methods


VerifyCheckbox

Verifies whether a control of the checkbox type has been checked or not, according to the (Boolean) "value" indicated.

verifyCheckbox(<controlName>, <value> [, <expected>] [, <context>])

View Parameters received by most of the methods


verifyControlValue

Verifies whether a control has the value indicated or not.

verifyControlValue(<controlName>, <value> [, <expected>] [, <context>])

View Parameters received by most of the methods


verifyControlEnabled

Verifies whether a control is enabled to edit or not (read-only).

verifyControlEnabled(<controlName> [, <expected>] [, <context>])

In iOS, this verification is always successful. In theory, in the API of Xcode you have an isEnabled property, but in the cases tested, it returns true every time.

View Parameters received by most of the methods


verifyMsg

Verifies whether an alert with a specific message sent with the msg command of GeneXus is presented.

This verification must be done both in the title and in the text of the alert.

verifyMsg(<string> [, <expected>])

View Parameters received by most of the methods


verifyControlVisible

Verifies whether the control is visible on the screen or not.

verifyControlVisible(<controlName> [, <expected>] [, <context>])

View Parameters received by most of the methods


verifyScreenshot

Takes a screenshot of a control or the entire screen and compares it to a reference image. If the comparison fails, the test fails.

verifyScreenshot(<reference> [, <controlName> [, <context>]])

View Parameters received by most of the methods

The reference parameter is of string type and identifies the reference image within the current test.

Note: Using this function requires some additional setup. You can find more information in Visual testing in Native Mobile applications.

The verifyScreenshot method is available as of GeneXus 17 upgrade 7.


IsControlEnabled

Similar to VerifyControlEnabled but returns a boolean instead of failing the test.

If the control is not found, the command fails with an assert.

IsControlEnabled(<controlName> [, <context>]): Boolean

View Parameters received by most of the methods


IsControlVisible

Similar to VerifyControlVisible but returns a boolean instead of failing the test.

If the control is not found, the function returns False.

IsControlVisible(<controlName> [, <context>]): Boolean

View Parameters received by most of the methods


IsShowingMessage

Returns True if an alert is being displayed on the screen.

Note: It does not take into account system alerts, for example, if it is asking for permission to receive notifications. 

IsShowingMessage(): Boolean

GetControlValue

Gets the value of the control and returns a string.

If the control is not found, the command fails with an assert.

GetControlValue(<controlName> [, <context>]): VarChar

View Parameters received by most of the methods


GetCheckboxValue

Similar to VerifyCheckbox, returns a boolean with the value of the checkbox.

If the control is not found, the command fails with an assert.

GetCheckboxValue(<controlName> [, <context>]): Boolean

View Parameters received by most of the methods


GetGridRowsCount

Similar to VerifyGridRowsCount, returns an integer with the number of rows in the Grid.

If the Grid is not found, the test fails with an assert.

GetGridRowsCount(<controlName> [, <context>]): Numeric(8)

View Parameters received by most of the methods


GetMessageText

If there is an alert on the screen, it gets the text of the alert. Similar to VerifyMsg.

If the alert is not found, the command fails with an assert.

GetMessageText(): VarChar

VerifyCondition

Receives a boolean and optionally a message, if the boolean is False then it fails the test and uses the message as the reason for the failure.

VerifyCondition(<boolean value> [, <message>])

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant