Silk Mobile

Table of Contents (Homepage)

GetAllValues

GetAllValues (String Zone, String Element, String Property)

images/images/os-icons/os_ios_150x150.png

images/images/os-icons/os_android_150x150.png

images/images/os-icons/os_windows_150x150.png

images/images/os-icons/os_blackberry_150x150.png

Description

Get all the values of a certain property from all the existing elements. Possible properties are all the methods available on the Object spy for the page.

Parameters

  • Zone Select Zone of an example element.

  • Element Select identifier of an example element.

  • Property – Select the property you want to get back from all the matching elements.

Usage

Scenario: This command will be useful when you are looking to pull a certain property from all the elements on a list or table. By using an example element as a reference this command will return the property of all the other elements.

Example: In the following example we will use the demo application EriBank. We will extract the text values of all the elements in the following list of countries.

images/download/attachments/2689183/1.jpg

Command usage: All the rows on the list have the same ID. We are going to get the text of all rows using this ID.

Parameters:

  • Zone - Select the example element's zone - in this case NATIVE.

  • Element - Element element's identifier. We will use an x-path query to identify a row in the table: xpath=//*[@id='countryList']/..//*[@id='rowTextView'].

  • Property - The property or method to be extracted from the elements that meet the query. In this case text.

Results:

The command will returns an array string of all the rows visible on the screen:

India

USA

Iceland

Greenland

Switzerland

Norway

New Zealand

Greece

Italy

Ireland

China

Japan

France

Code Examples

Java Example
String [] strArray = client.getAllValues("NATIVE", "xpath=//*[@id='countryList']/..//*[@id='rowTextView']", "text"); 
C# Example
string [] strArray = client.GetAllValues("NATIVE", "xpath=//*[@id='countryList']/..//*[@id='rowTextView']", "text");
VBScript Example
client.GetAllValues "NATIVE", "id=rowTextView", "text"
ListSize = Cint (client.GetLastStringArrayLength)-1
ReDim GetValue(ListSize)
For Iterator = 0 To (ListSize)  
GetValue(Iterator) = client.GetLastStringFromArray(Iterator)
Next
Report

Note: This is also the implementation for the command in our UFT AddOn.

Python Example
var = self.client.getAllValues("NATIVE", "xpath=//*[@id='countryList']/..//*[@id='rowTextView']", "text")
Perl Example
my @strArray = $client->getAllValues("NATIVE", "xpath=//*[\@id='countryList']/..//*[\@id='rowTextView']", "text");