Mobile Development 10.11 | webMethods Mobile SuiteWeb Help | webMethods Mobile Designer Native User Interface Reference | Mobile Designer Native User Interface | Using Element Identifiers
 
Using Element Identifiers
It can be tedious to test applications manually. A number of UI automation tools, such as Appium, have become available. Mostly, these tools enable you to run test scripts to access UI elements on the screen in a number of ways. Commands may be available to press or swipe at literal pixel positions, find elements according to their index in a parent object, or search for elements by a unique name assigned by the application developer and the item's type.
Mobile Designer provides a new Element Identifier API. This allows you to annotate your NativeUI objects with a unique name so that they can be detected by UI automation tools. For Android devices, the content description field of an element can be set, and on iOS, the accessibility identifier is used.
Note:
It can be important to set an element's identifier before the element is drawn on the screen for the first time. For some elements, it is not always possible to update the value later.
For most elements, the setElementIdentifier() method is used directly:
nUIButtonElement myButton = new nUIButtonElement(-1, "Save Preferences");
myButton.setElementIdentifier("SavePrefs");
...
aView.add(myButton);
When annotating certain other elements, the methods to do so change slightly. Defining panes in windows is done as follows:
nUIWindowDisplay myWindow = new nUIWindowDisplay(-1);
myWindow.setPaneDimensions(2, sidePaneDimensions, "SideMenuPane");
Similarly, updating pop-up menus is done as follows:
nUIPopupMenuBuilder builder = new nUIPopupMenuBuilder();
builder.addItem("List Tasks", new TaskLister(), "StartListTasks");
builder.addItem("Update Tasks", new TaskUpdater(), "StartUpdateTasks");
For the following elements, the setElementIdentifier() method is not supported:
*nUISearchNavButton - Not supported on iOS.
*nUISeparatorElement - Not supported on Android.
*nUISpacerElement - Not supported on iOS.
*nUITabView - Not supported on iOS.
*nUITabElement - Not supported on Android.
*nUIWebviewElement and nUIWebView - Not supported on Android.
For further information, see webMethods Mobile Designer Java API Reference.
Note:
Mobile Development sets element identifiers automatically using the name of the elements from the application model.