Silk Mobile

Table of Contents (Homepage)

IsElementFound

IsElementFound( Zone, Text, 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

images/images/os-icons/os_symbian02_150x150.png

images/images/os-icons/os_windows_mobile_150x150.png

Description

Check if a given element or text is found in the specified zone; if found returns TRUE if not found returns FALSE

Parameters

  • Zone - Select Zone

  • SearchElement - what to search for: select Element from the drop-down list OR (for OCR text identification) insert text into the empty box in the drop-down list

  • Index - Element or text index

Usage

Scenario: In the following scenario we will verify that the ‘Register’ button appears upon entering the ebay application.

images/download/attachments/2689233/1.jpg images/download/attachments/2689233/2.jpg

  1. Enabling the Object Spy to grab a unique native identifier for the ‘Register’ button.
    images/download/attachments/2689233/3.jpg

  2. By marking the button, we can get all the element's properties. By checking on the XPath filter, we can see that path=//*[@text='Register'] uniquely recognized the element.

  3. Adding a command of isElementFound(Zone, Element, Index) command with the following parameters:

    1. Zone: NATIVE

    2. Element: xpath=//*[@text='Register']

    3. Index: 0

Code Examples

Java Example
if(client.isElementFound("NATIVE", "xpath=//*[text='register']", 0)){
// If statement
}
C# Example
if(client.IsElementFound("NATIVE", "xpath=//*[text='register']", 0)){
// If statement
}
VBScript Example
If StrComp (client.IsElementFound ("NATIVE", "xpath=//*[text='register']", 0 ), "True") = 0 Then
Report
'If statement
Else
Report
End If
Python Example
if(self.client.isElementFound("NATIVE", "xpath=//*[text='register']", 0)):
# If statement
pass
Perl Example
if($client->isElementFound("NATIVE", "xpath=//*[text='register']", 0)){
# If statement
}