Silk Mobile

Table of Contents (Homepage)

GetElementCount

GetElementCount ( Zone, Element)

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

images/images/os-icons/os_symbian02_150x150.png

images/images/os-icons/os_windows_mobile_150x150.png

Description

Count the number of times an element or text is found.

Parameters

  • Zone: Select Zone.

  • Element: Common identifier to all the elements to count.

Usage

Scenario: In the following example we will check how many tiles there are on the current screen of the device.

images/download/attachments/2689280/1.jpg

Step 1: We will look for a common property for all the tiles.

In this case will be set to “xpath=//*[@class='android.widget.TextView']”

Step 2: We will use the getElementCount command to count number of tiles on the screen.

Parameters:

  • Zone: Select Zone

  • Element: “xpath=//*[@class='android.widget.TextView']”

Code Examples

Java Example
int int0 = client.getElementCount("NATIVE", "xpath=//*[@class='android.widget.TextView']");
C# Example
int int0 = client.getElementCount("NATIVE", "xpath=//*[@class='android.widget.TextView']");
VBScript Example
int0 = client.getElementCount("NATIVE", "xpath=//*[@class='android.widget.TextView']")
Report
Python Example
ar2 = self.client.getElementCount("NATIVE", "xpath=//*[@class='android.widget.TextView'] ")
Perl Example
my $int2 = $client->getElementCount("NATIVE", "xpath=//*[\@class='android.widget.TextView'] ");