Silk Mobile

Table of Contents (Homepage)

ElementGetText

ElementGetText ( Zone, Element, Index)

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 text from element - The text will be saved as a string.

Parameters

Usage

Scenario: We will use the Eribank demo application.

After selecting the country from the country list using the elementListSelect command, we would want to confirm that the text on the Country text field is indeed what we choose.

images/download/attachments/3310654/05.jpg

The command to run

images/download/attachments/3310654/06.jpg


The result (from the console log)

images/download/attachments/3310654/07.jpg


Note

By default elementGetText will return the first 255 characters.

To change the default text length use the command setProperty with name of the property "max.text.size".

For example:

client.setProperty("max.string.size", "500");

Code Examples

Java Example
String str0 = client.elementGetText("NATIVE", "xpath=//*[@id='countryTextField']", 0);
C# Example
String str0 = client.elementGetText("NATIVE", "xpath=//*[@id='countryTextField']", 0);
VBScript Example
str0 = client.ElementGetText ( "NATIVE", "xpath=//*[@id='countryTextField']", 0 )
Report
Python Example
var0 = self.client.elementGetText("NATIVE", "xpath=//*[@id='countryTextField']", 0)
Perl Example
my $str0 = $client->elementGetText("NATIVE", "xpath=//*[\@id='countryTextField']", 0);