Silk Mobile

Table of Contents (Homepage)

WaitForElement

WaitForElement(String Zone, String Element, int Index, int Timeout)

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

Sets sleep until element is identified.

Parameters

  • Zone: Select Zone

  • Element: Query to identify the objects/Name of the element on the object repository.

  • Index: Element Order (the number of times the element appears more than once). Index=0 refers to the first appearance of the element; Index=1 refers to the second appearance of the element, etc.

  • Timeout: Waiting Timeout in milliseconds.

Usage

Scenario: On the following scenario we will try to create an account on gmail.com.
We will see that it might take time to load the page, so by adding a step of waitForElement the test stability is improved.

Step 1: Launch google.com using the chrome browser.

Step 2: Click the create an account button.

Step 3: Fill in name on Name text field.

Test:

images/download/attachments/2688947/1.jpg

Web page was not fully loaded. Element was not identified before the click command's timout which resulted on the test failing.

How to resolve this issue

We will use the WaitForElement command. Silk Mobile will wait for the element and it will not move to the next step.

images/download/attachments/2688947/2.jpg

Code Examples

Java Example
client.waitForElement("WEB", "id=FirstName", 0, 10000)
C# Example
client.WaitForElement("WEB", "id=FirstName", 0, 10000)
VBScript Example
client.WaitForElement ("WEB", "id=FirstName", 0, 10000)
Python Example
self.client.waitForElement("WEB", "id=FirstName", 0, 10000)
Perl Example
$client->waitForElement("WEB", "id=FirstName", 0, 10000)